empty plot matlab code?

2 Ansichten (letzte 30 Tage)
Deema42
Deema42 am 1 Feb. 2017
Bearbeitet: Deema42 am 1 Feb. 2017
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 Kommentare
Deema42
Deema42 am 1 Feb. 2017
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 am 1 Feb. 2017
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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by