Matlab wont plot anything
古いコメントを表示
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 件のコメント
John Chilleri
2017 年 2 月 6 日
Well for one, your while loop is infinite. n is "less than" 26 always, and you don't ever change its value.
Daniel Espinoza
2017 年 2 月 6 日
John Chilleri
2017 年 2 月 6 日
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
2017 年 2 月 6 日
John Chilleri
2017 年 2 月 7 日
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
2017 年 2 月 7 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!