Matlab wont plot anything
Mostrar comentarios más antiguos
I have read several people asking about why their matlab wont plot anything. I still can't figure out why mine wont plot. This is my code
>> close all
>> n=1:25;
>> R(n) = -80;
>> while n<26
R(n+ 1) = -0.8*R(n);
end
plot(n,R(n))
once I type end and press enter, the hashmark showing exactly where you are typing disappears and stops blinking so I feel like my plotting isn't going through. I don't know if that has anything to do with it. Another thing I notice is that why it shows >> for previous statements and once I enter the while n<26 line, it doesn't give me anymore >> lines. I am very inexperienced with Matlab, any help is highly appreciated. I've read figure() helps some people, where exactly in my code am I supposed to type this?
Also, when I close my matlab it says "an operation is in progress....." I don't know if this matters.
6 comentarios
John Chilleri
el 6 de Feb. de 2017
Well for one, your while loop is infinite. n is "less than" 26 always, and you don't ever change its value.
Daniel Espinoza
el 6 de Feb. de 2017
John Chilleri
el 6 de Feb. de 2017
If you tell me what you would like the code to do I'd be glad to help you fix your code!
Are you trying to set the values in R(n) = -.8*previous value? Or only multiply some of them by -.8 or what is your goal?
Daniel Espinoza
el 6 de Feb. de 2017
John Chilleri
el 7 de Feb. de 2017
So your problem provides that R(1) = -80, and you need to compute R(2 through 25) and then plot R.
The first step is similar to what you have,
R(1) = -80;
but now you need to loop through the remaining 24 values.
As Walter Roberson described below, try thinking of how a for loop can be used to solve this problem.
Daniel Espinoza
el 7 de Feb. de 2017
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Graphics Performance en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!