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

Amazon Auto Links: No products found.

Thanks, helped a lot

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.

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.?

Thanks this helped me finish my homework.

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

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??

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

explains very well

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

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

I love you. Thank you so much.

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

thanks for the helpful and clear explanation!

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

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

plz help

A BIG THANK YOU

Thank you for posting! You explained things really well.

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

thanks for the help

Thanks for the help man, much appreicated 🙂

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

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

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.)

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

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.

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

awesome!

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

excellent

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.

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.

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.