empty plot matlab code?

조회 수: 2 (최근 30일)
Deema42
Deema42 2017년 2월 1일
편집: Deema42 2017년 2월 1일
when i try to run the following code, i get an empty plot, and the "initial" variable is NaN, what is the problem? "note: The meijerG function is attached as an m.file"
close all;
ls1=3;
change=2; %k
lmda=.1; step = 0.1; y = 0.00001:step:4; initial=0; p=1;pint=.5; for d=0:2 for r=0:2 for w=0:2 for l=0:2
% change=(-n-r-w).*(2/ls1);
n=change.*ls1.*5+r+w;
aj=(gamma(w+change.*ls1.*.5+r))./(gamma(change.*ls1.*.5+r));
bj=(gamma(w-d-.5.*change))./(gamma(-d-.5.*change));
c=((-1).^l.*exp(.5.*(-lmda.*p+ls1+lmda*pint)).*(lmda.*p.*.25).^d.*(.25.*ls1.*lmda.*pint).^r)./(4.^(1+change.*.25-1+.25.*change.*ls1).*factorial(d).*factorial(r).*gamma(d+.5.*change));
f=c.*((aj.*bj)./(((-1).^(-w))).*2^(-change.*ls1.*.5-r-w).*factorial(w).*((factorial(n+l-1))./(factorial(l).*factorial(n-l)))).*y.^(change.*.5+l+d).*MeijerG({[1-change./2-d-l], []}, {[0], [-.5.*change-d-l]}, (y/2));
initial=initial+f;
end
end
end
end
plot(y, initial,'b');
  댓글 수: 4
Deema42
Deema42 2017년 2월 1일
no i didn't actually. i don't know how, i tried to see if there is a division by 0, but i didn't find a problem
Adam
Adam 2017년 2월 1일
In the editor just click in the column immediately to the right of the line number on the left to place a breakpoint. Then when you run your code it will stop here and you can look at your variables on the command line.
Replacing a parfor loop with a for loop is trivial and so is breaking down a line of code into multiple variables, apart from the usual issue of trying to find an intelligent name for intermediate maths variables, but since you are just going with letters of the alphabet anyway there's a fair few of them to go at.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by