empty plot matlab code?

1 次查看(过去 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