Error using pdepe function in matlab.

조회 수: 13 (최근 30일)
Brian
Brian 2018년 2월 9일
댓글: Brian 2018년 2월 20일
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?

답변 (1개)

Torsten
Torsten 2018년 2월 9일
Call pdepe in a loop for M = M_array(1),M = M_array(2),...
Best wishes
Torsten.
  댓글 수: 10
Walter Roberson
Walter Roberson 2018년 2월 20일
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 2018년 2월 20일
Thanks Walter! This helps.

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

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by