Error using pdepe function in matlab.
11 views (last 30 days)
Show older comments
The code runs well with M as a numeric but when I change it to a range of values, it gives me a error. How can I rectify this?
0 Comments
Answers (1)
Torsten
on 9 Feb 2018
Call pdepe in a loop for M = M_array(1),M = M_array(2),...
Best wishes
Torsten.
10 Comments
Walter Roberson
on 20 Feb 2018
Torsten had suggested
z1 = heaviside(M-Me);
z2 = heaviside(M-Ms);
z3 = heaviside(eta-u(3));
where M was the interpolated value based upon x. You replaced the heaviside with calls to Untitl that reads the entire .cvs file and uses all of it instead of using the interpolated value -- and without even differentiating between the two columns of the file at that.
Do not read the entire file there. Pass in the current M value to your Untitl function and use that.
I notice, by the way, that your heav function calculates a constant eta and compares that to the input parameter, and that your weakly-named Untitl just does comparisons, acting as a heaviside function. I would suggest to you that it would make more sense to have a function that calculated eta once and return that, and then to have a heaviside function that did nothing but heaviside, and pass in the appropriate difference between eta and whatever. Or don't bother with an explicit heaviside and instead code
z1 = M > Me;
z2 = M > Ms;
z3 = eta() > u(3);
where
function eta_val = eta()
phi =100;
lambdaphi = 4.9*10^(-3);
phic = 60;
lambda0 = 10* lambdaphi.*phi;
eta_val = (lambdaphi/lambda0)*phic;
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!