필터 지우기
필터 지우기

How can I add two sets of results with different size?

조회 수: 3 (최근 30일)
Faezeh Manesh
Faezeh Manesh 2020년 4월 10일
댓글: Faezeh Manesh 2020년 4월 12일
Hello all,
I have two sets of data which are as follows:
T1:1x4655757 dndT1: 1x4655757,
T2:1x45669 dndT2: 1x45669,
The above results are obtained as a result of solving a differential equation on the same T interval but with two different parameters (two different B):
dndT=a*exp(B/T)*(1-n);
where a and B are constants.
I want to add these two results up (dndT1+dndT2). I don't know how can I do that. Can anyone help me with that.
  댓글 수: 2
Akira Agata
Akira Agata 2020년 4월 10일
Questions for clarification:
  1. "same T interval" means T1 and T2 cover the same range? (such like T1(end) - T1(1) = T2(end) - T2(1) ?)
  2. Another parameter in the equation n is also constant?
Faezeh Manesh
Faezeh Manesh 2020년 4월 10일
Yes, you are right. They cover the same range

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

채택된 답변

Walter Roberson
Walter Roberson 2020년 4월 10일
I suggest that when you call ode45 that you pass in a vector of multiple times instead of two times exactly. When you pass two exactly, ode45 reports output whenever it feels like it, which could end up being different number of times for different B values. When you pass a vector of 3 or more times it reports back at those times only. You would then get the same length of results in the output and so would be able to add directly.
  댓글 수: 5
Walter Roberson
Walter Roberson 2020년 4월 10일
I suggest linspace(294,361,1e6)
Or possibly more than 1e6. The first one must be oscillating a lot if it feels that it needs 4e6 outputs.
I wonder if you should use ode23s? I suspect that you have a stiff system.
Faezeh Manesh
Faezeh Manesh 2020년 4월 12일
This works well. Thanks a lot.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by