No graphs after plot command

조회 수: 2 (최근 30일)
semiha
semiha 2015년 2월 15일
댓글: semiha 2015년 2월 15일
Hello everybody; I have a question about plot command. When i run the script, there is no error message but empty figure has appeared. I couldn't solve this problem using gcf or noFigure = 1; figure(noFigure); command. What should i do to see the graph? Thanks for your help
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2015년 2월 15일
Semiha - what is the script that you are using? What code is being used to plot something to the figure? Please provide more details.
Star Strider
Star Strider 2015년 2월 15일
semiha’s ‘Answer’ moved here ...
a = 100;
m = 1000;
n = 1000;
h = a/m;
t1 = 100;
k = t1/n;
x = 0:h:a;
t = 0:k:t1;
D = -k;
w0 = zeros(1,m+1);
w = zeros(n+1, m+1);
A = zeros(m+1, m+1);
B = zeros(m+1, m+1);
for j = 1:m+1
w0(j) = (1-(5*(1-3*i))/((1+6*(x(j)^3))));
end
w(1,:) = w0;
for p=1:n
for j=1:m+1
A2 (j)= k*1*i;
A(j,j) = A2(j);
end
for j=1:m
A(j,j+1) = 1 - 1i*D*abs(w(p,j)).^2;
end
for j=1:m-1
A(j,j+2)=k*1*i;
end
A(m,m)=k*1*i;
A(m,1)= 1 - 1i*D*abs(w(p,j)).^2;
A(m,2)=k*1*i;
A(m-1,1)=k*1*i;
A(m-1,m)= 1 - 1i*D*abs(w(p,j)).^2;
A(m-1,m-1)=k*1*i;
r =(A)*w(p,1:m+1)';
w(p+1,1:m+1)=r';
end
plot3 ( x, t,(abs(w(n,:))) );

댓글을 달려면 로그인하십시오.

답변 (1개)

emehmetcik
emehmetcik 2015년 2월 15일
Your output variable "w" mostly consists of "nan" (not a number) values. Probably the result of zero divided by zero at some point.
Only the first few rows of "w" have no nan's.
  댓글 수: 3
emehmetcik
emehmetcik 2015년 2월 15일
I'm not quite sure what the code does. But the problem seems to be that some values grow exponentially.
My recommendation is that you should re-check your code. The following commands can be useful as well:
dbstop if naninf
This will automatically put a debug point when a nan or inf value is encountered while the code is being executed.
dbclear all % To clear all debug points
semiha
semiha 2015년 2월 15일
yes you are right i used dbstop if naninf command, it seems that one line creates this situtation. ( A(j,j+1) = 1 - 1i*D*abs(w(p,j)).^2) i should use this line to get a correct answer, but i will try to change it. Thanks

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by