MATLAB While Loop Tutorial

This is a tutorial on how to write and use While Loops in MATLAB. Table of contents below.

00:00 – Introduction
00:34 – General form
01:15 – Example 1
02:34 – Example 2
05:27 – Using While loops like For loops
08:18 – Conclusion

Comments

Joshua Richards says:

Thanks, helped a lot

Harjinder Singh says:

Thank You. Just wanted to ask how do you store results in a vector for while loop? Because you wouldn’t know what size zero vector to create before the while loop.

jointcc2 says:

hi ive got a question, what is a(counter) and does sum_a equal 0 in every new loop and a(counter) just becomes 1,3,6,10… respectively to make the sum equal to 1,3,6,10…etc.?

Leul Assamenew says:

Thanks this helped me finish my homework.

Dhruvo DZ says:

at 8:50 could u explain a(counter)??

Jacqui Chetty says:

this is fantastic. I am going to show this to my students, i am a lecturer at a university. Could i save the video and show it later, offline??

sjusie says:

Thank you so much. I was stuck on how to make a while loop repeat a certain action, your video really helped. 

王晓君 says:

explains very well

Dacoda Ray Davis says:

How might someone using a while loop to find the first factorial to exceed a certain number? for example, the number 110,000,000,000

HR NOH says:

I have a question. Why do need there ‘+5000’ next to ‘1.08*bal’? I think ‘1.08*bal’ contains deposit.

Morgan Fudgsiclemonster says:

I love you. Thank you so much.

Yvonne Chang says:

hello, can matlab do infinite loop? like always show receive data from the input , thx

marieflauto says:

thanks for the helpful and clear explanation!

Taiwo Babatunde says:

I love your teaching, how can I get or download 34 bus system cos I have search not get it
all throughout but I could not get it.thanks sir

Ben H says:

Just curious how to use MATLAB to find the values of two symbols?
a+c=30 and 2<= c-a<=10 Both a and c are within a function and I need to find the min and max values of a? Any help would be greatly appreciated

Ap vlogs says:

plz help

Edward Chida says:

A BIG THANK YOU

Anonymous says:

Thank you for posting! You explained things really well. 

ShaunJW1 says:

I’m using Octave GNU. My fuck is it a piece of shit….

Spartan159 says:

thanks for the help

Mahali Matehe says:

Thanks for the help man, much appreicated 🙂

Dacoda Ray Davis says:

I’m trying to run an equation a certain amount of times, but I haven’t been able to get it to work on a while loop. the code I have is
k = 0.9987;
n = 100;
counter = 0;
final_count = 694;
while counter <= final_count;          if (k*n)=curr_n             curr_n = n             counter = counter +1          end end Please help! Thank you! And if you think it'd be better to switch it to a for loop 

HotDaffodil says:

How do turn what you’ve marked into “explanation format” so easy?(the green text with a % in front of it)

gtactwit says:

Hey I have a question: how can you make a while loop that repeats until a certain variable, vector L, does not change? I though about starting with “while K ~= L” and then put “K = L;” before the for-loop that changes L, but then the while-loop, of course, stops immediately.

(To be more specific, I have an assignment for which I need to write a function that implements the k-means algorithm.)

xu jiaqi says:

got midterm tomorrow(literally today), this video just give me 5 more points!

Ap vlogs says:

Write the JavaScript to read a positive number from the user and then print
to the console the numbers from 1 to the user entered number.
Ex. If the user enters 50, you should print the numbers 1 to 50 in the
console.

Brian Evans says:

Thanks for the great tutorial, you’re much better than my lecturer!

Jigar Patel says:

awesome!

Audun Lode says:

Two questions:
1. At 1:17 you make the 3 lines “%” how do you do that?
2. how do you get that big letters?

Btw thanks for the video. really helped – this is actually easypeasy

Kunu Kunu says:

excellent

Feyisola Adejokun says:

i still don’t understand this line of code – sum_a = sum_a + a(counter). specifically the a(counter) part. Sorry, if its a stupid question. But i have seen you do this in your for loops video. why can’t i just use ”sum_a=sum_a + counter”. I get the same answer with you if i do this. And this makes more sense to me or maybe I still don’t understand the a(counter) part.

Harshit Jhuria says:

Thanks for the video man! Great work! I encourage you to do more of such videos in a little more depth to make it more clear to students like me. I have found a little help over this subject till now.

Mikej1592 says:

I wondered in real world terms ie. getting half a percent interest as in real bank accounts savings, and able to deposit 1000 a year to see how long it would take to get to a million dollars.  Just have to live 359 years and I would have 1.0045e+06 dollars… while that is seriously depressing, I did find this a very helpful tutorial.

 Write a comment

*

Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!