How to plot all results in a for loop?
1 view (last 30 days)
Show older comments
I have tried to plot a 2D figure for a for loop function but the results does nor show in one figure?
My code:
function fluid_dynamics
F=input('Enter the inpulse force:');
for x=0:0.1:8*pi;
y1= F*exp(-0.246*x)*sin(0.806*x);
end
figure
plot(x, y1, 'r*');
0 Comments
Accepted Answer
Image Analyst
on 3 Nov 2014
You forgot to put an index for y1. Try this:
fontSize = 30;
F=input('Enter the inpulse force:');
x = 0 : 0.1 : 8*pi;
for index = 1 : length(x)
y1(index) = F * exp(-0.246*x(index)) * sin(0.806*x(index));
end
figure
plot(x, y1, 'r*-', 'LineWidth', 3);
xlabel('x', 'FontSize', fontSize);
ylabel('y1', 'FontSize', fontSize);
grid on;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
0 Comments
More Answers (0)
See Also
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!