Error using pdepe function in matlab.

11 visualizaciones (últimos 30 días)
Brian
Brian el 9 de Feb. de 2018
Comentada: Brian el 20 de Feb. de 2018
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?

Respuestas (1)

Torsten
Torsten el 9 de Feb. de 2018
Call pdepe in a loop for M = M_array(1),M = M_array(2),...
Best wishes
Torsten.
  10 comentarios
Walter Roberson
Walter Roberson el 20 de Feb. de 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;
Brian
Brian el 20 de Feb. de 2018
Thanks Walter! This helps.

Iniciar sesión para comentar.

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by