이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
previous technique didnt work for the present code
조회 수: 1 (최근 30일)
이전 댓글 표시
function main
so=1;
c=-1.25;
% a=1;
Pr=1;
%n=2;
n=input('n=') %%n=-0.3,-0.5
x=[1 1];
x1=fsolve(@solver,x);
function F=solver(x)
[t,u]=ode45(@equation,[0,20],[so c 1 x]);
s=length(t);
F=[u(s,2)-1; u(s,4)];
end
figure(1)
plot(t,u(:,4),'b-');
hold on
function dy=equation(t,y)
dy=zeros(5,1);
dy(1)=y(2);
dy(2)=y(3);
dy(3)=y(2)^2-y(1)*y(3)-1;
dy(4)=y(5);
dy(5)=Pr*(n*y(2)*y(4)-y(1)*y(5));
end
end
ERROR is
code is not running
댓글 수: 21
Rik
2019년 2월 24일
편집: Rik
2019년 2월 24일
Since you don't have any comments, I don't have a clue what your goal is. But the source of your problem is that you call the solver with 4 elements in y, but inside the solver you assume that there are 5.
Also, you seem to be repeating the same code several times, as well as repeating the nested function equation. And the clc;clear all; at the beginning of your code is useless (or at least the clear all is, since a function will start with an empty workspace anyway (unless you have input variables).
MINATI
2019년 2월 24일
I want to draw
- u(:,4) w.r.t t (in X-axis) first
- u(:,4) w.r.t Pr (in X-axis, continuous range, say, from 0 to 7) and for different values of so=1,2,3
N.B: Dual solution concept so program is repeated
Thanks in advance
Jan
2019년 2월 25일
By the way: a clear all is a complete waste of time on top of a function. Why clearing an empty workspace? Removing all functions from the memory wastes time with reloading them from the slow disk.
MINATI
2019년 2월 26일
Dear Jan
Can we proceed with the code.
Yeh actually the lines makes no role in code but I am running the code repeatedly but to avoid confusion with previous ERROR msg.
Pl. help here
Jan
2019년 2월 26일
The clear all does not avoid confusion, but is useless only. Keeping two functions with the same name and contents in the same file is confusing also, even if they are on different levels of nesting. This does not look like a "Dual solution concept", but like obfustcation. As you see, such tricks impede the debugging.
MINATI
2019년 2월 26일
Dear Jan
First Thanks for your valuable time and suggestion
According to your suggestion I have somehow corrected my fault but still the code is not running. What to do now?
Jan
2019년 2월 26일
편집: Jan
2019년 2월 26일
As far as I understand, you want to run this:
function main
so = 1;
c = -1.25;
Pr = 1;
n = 2;
x = [1, 1];
x1 = fsolve(@solver, x);
[t, u] = ode45(@equation,[0,20], [so, c, x1(1), 1, x1(2)]);
figure(1)
plot(t, u(:,4), 'b-');
hold on
function F = solver(x)
disp(datestr(now, 0))
[t, u] = ode45(@equation, [0, 20], [so, c, 1, x]);
F = [u(end, 2) - 1; u(end, 4)];
end
function dy = equation(t, y)
Pr = 1;
dy = zeros(5,1);
dy(1) = y(2);
dy(2) = y(3);
dy(3) = y(2)^2 - y(1) * y(3) - 1;
dy(4) = y(5);
dy(5) = Pr * (n * y(2) * y(4) - y(1) * y(5));
end
end
"Is not running" does not explain, what you observe. Please post this.
It is hard to modify the code, because you did not tell us, what the code should do. A not runnming piece of code keeps its purpose as secret, if the programmer did not inset exhaustive comments.
MINATI
2019년 2월 26일
%Here is the qn with B.C for REF:(Dual solu needed)
f'''+ff''-(f')^2+1=0,
g''+Pr[fg'-nf'g]=0,
%f(0)=so,f'(0)=c,f'(inf)=0,
g(0)=1,g(inf)=0.
Jan
2019년 2월 26일
"it takes so much of run time" - please tell us any details: How much time does it need and what do you expect?
"Here is the qn with B.C for REF:(Dual solu needed)" - this sounds like pure magic to me. Please care for the non-native speakers like me and use full english words. Thank you.
MINATI
2019년 2월 26일
I have given the differential equation:
f'''+ff''-(f')^2+1=0,
g''+Pr[fg'-nf'g]=0,
with initial and boundary conditions
f(0)=so,f'(0)=c,f'(inf)=0,
g(0)=1,g(inf)=0.
After running the code for one value of x, say 1, we will get one solution and then we need to change the value of x,say , for 5, another solution(dual) came into picture.
Jan
2019년 2월 26일
I cannot run this code "for one value of x", because the formula does not contain any "x". Therefore I do not know, what changing its value to 5 is any kind of "dual". You cannot implement boundary conditions at Inf.
Jan
2019년 2월 26일
Sorry, MINATI, I do not get what you want to do. In your comment above (link) you wrote "running the code for one x", but the formula does not contain any "x". Then the explanation "we change the value of x (manually)" does not clarify my question.
MINATI
2019년 2월 27일
First we run the program with x=[1, 1] ; we will get one curve, keeping the curve, we need to change x=[1, 0] OR x=[2, 1] some thing like this.
Please for reference follow this video: https://www.youtube.com/watch?v=eSdebB_oyMM
Jan
2019년 2월 27일
@MINATI: Again and for the last time: The formula you have posted does not contain an "x". So you cannot run it with different values for x.
It is not efficient, if I watch internet videos about your problem, because it is your turn to understand the mathematical problem. This forum cares about the implementation in Matlab only. It is not clear to me, what the actual question is and you react to my questions for clarifications by repeating the formerly posted statements. This does not make the problem clear.
I suggest to drink a cup of coffee. Reformulate the problem. Post a minimal example, which demonstrates the problem and explain clearly, what you want to solve and what you observe. Maybe opening a new thread is a good idea, because this one is confusing now. If you do so, mention this thread as a link.
MINATI
2019년 2월 27일
ok Jan
I had created a new one
https://in.mathworks.com/matlabcentral/answers/questions/new/?s_tid=gn_mlc_ans_ask
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MuPAD에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)