Getting values for equation written in for loop but not getting plots

B
Brooklynn · Dec 8, 2020 · 1.8K views
Question
Not getting plots written in for loop, but getting values in command window
Expert Answer
Profile picture of John Williams
John Williams PhD Expert
Answered Aug 14, 2026
rol = 5:10;
plot(rol,V2fl);
you dont need for loop when you are using element wise multiplication .*
delete the loop and plot again or
Otherwise you can use index of for loop without .* in eqn
 
V2fl(rol) = ((2*3.14)...);
figure(1)
hold on
plot(rol,V2fl)


Another way

Replace your plot(r,z_1) with this:
 
plot(r,z_1,'.'); hold on
If you don't turn the "hold" to "on" then the figure is overwritten with each iteration.
You can also achieve this by adding these commands before the loop:
 
figure; hold on
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!