## MATLAB Tutorial 3 – FOR Loops and Plots

An introduction to basic “for” loop logic and some tips to make clear, visually appealing plots easily.

• Views:89,517 views
• Rating:
• Categories:
• Tags:

Dante Arturo Rodríguez Camacho says:

+Numerical Methods ChE McMaster  I just wanted to let you know that I have had a very hard time these last years trying to learn matlab basics and your videos (which I just recently discovered) have really helped me and inspired me to keep learning matlab. I really enjoy your videos!  Thank you so much!!!!

amazing. thanks a lot

Marcus Masdammer says:

How would I create a loop that would plot a graph with an unknown max time, but once a value becomes 0 the plotting of the graph stops.
Thanks.

kaznW says:

Is that a Dark Souls wallpaper i see? ^^

Hafiz M. Waqas says:

very good tutorial. thank you so much. it is really very helpful

Kishan dey says:

thanks for the nice explanation.. also can u please provide a tutorial video with an equation of the form where equation is dependent on two variables, say like velocity is dependent on both position ‘x’ and time ‘t’ and both of which are in summation form??

skankhunt42 says:

@05:08, Can you please tell me why didn’t you put brackets for 0:0.01:10?

ruthwick reddy says:

bro thanks a lot……………

RobosergTV says:

Mechanical freaks says:

OMG you are a life saver dude

Omar Sharief says:

very good

Farzin Motamedi says:

Thank you so much

Rocío González Meza says:

thanks! now it seems easy (:

Jeet Sonwani says:

I don’t know why but the second method makes more sense to me.

Sheikh Farhana Binte Ahmed says:

These videos are the most understandable ones among all the matlab video tutorials that i have seen uptil now! please upload more videos. the teaching style is very effective.

Nik Hasyimi says:

+Numerical Methods ChE McMaster is there any ways to simplify the steps used to plot the graphs?maybe using a loop?
And i have some problems here, it just a simple problem regarding the column and row of the theta in LINE 34. For the function you used theta(1,:) = the functions, when i run it it will be 4×1001 matrix and it not the same as you which is 1001×4 matrix. I need to change the codes back to theta (:,1) to get the same result 1001×4 as you get. Can you explain this?

Luiz Gonzaga says:

Very good!

sandip vasani says:

Really Very Informative……….You have done Great Job.

Dharnisha Jayasundera says:

Good video boss but I prefer if you dont use the word “garbage “for mathematics and physics. This is not garbage. Reality shows are garbage.

MD. IMRAN Hossain says:

Jose Antonio says:

NICE!

Get crafty with Alex says:

This is by far the best youtube channel I have found for learning MATLAB! My teacher, as of now, does not “teach” anything and I have been very frustrated and found myself falling behind. Finding these have helped me catch back up with where everyone should be in class now! Thank you so much for such a great teaching style which I am able to fully understand and benefit from! These are a life saver! Please, keep it up! 🙂

Mohamed lamine Traore says:

very good

Thank you so much for your simplified explanation. I learned different things from this lesson.

brenna ryan says:

Studying for finals and this was SOOO HELPFUL!! THANK YOU!!

Ebu-Bekir Karan says:

Thank you so so so much. You helped me understand for loop.

sridhar babu mudhangulla says:

video was very helpful but there is a small confusion, i think if A(x,y) is a matrix then x represents the number of rows and y represents the number of columns but you are saying in a reverse manner which is confusing us.

Arman Khan says:

so in my class right now I have to plot the eigenvalues on a complex plane for varying values of k in my A matrix which is:
c = 2;
b = -.1;
A = [0 1; -c-k1 -b-k2];
eig(A);
I created a for loop:
k1 = 0:0.01:10;
for i = 1:length(k1)
k1(i);
end

I just don’t know exactly as to how to get the varying eigenvalues to output
(I know that I have to define k2 as well) using the for loop and then plot them…please help out if you can!

emperoy8 says:

Amazing Job. Well done

asfand khan says:

The natural numbers less than 10 that are multiples of 4 or 9 are 4, 8 and 9. Their sum is 21.Find the sum of all the multiples of 4 or 9 less than 1000. How would you find the matlab code for such a question? please help.