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!