How to insert constant offset into cumtrapz calculation?

1 回表示 (過去 30 日間)
Anna Jacobsen
Anna Jacobsen 2022 年 9 月 23 日
回答済み: Nipun 2023 年 12 月 22 日
I am doing data analysis according to the following equations from my professor.
For part of my data set, I want to use the cumtrapz function "normally" and for part of it I want to subtract a constant within the summation expression (C_p_baseline, as seen above). I have tried using the two options below and neither one worked. The output for each method is shown in the graphs below. I do not understand where the discontinuity comes from as the curve should decrease gradually from the maximum. I have attached the entire code so you can see the data. Any suggestions on how to embed the subtraction within the cumtrapz function like my professor showed?
Option 1:
H11 = cumtrapz(TC1(1:Tm),Cp1(1:Tm));
H12 = cumtrapz(TC1(Tm:end),Cp1(Tm:end)-dCp1);
Option 2:
H11 = cumtrapz(TC1(1:Tm),Cp1(1:Tm));
H12 = cumtrapz(TC1(Tm:end),Cp1(Tm:end))-dCp1;
  1 件のコメント
Torsten
Torsten 2022 年 9 月 23 日
編集済み: Torsten 2022 年 9 月 23 日
We can't comment since we don't know your data.
But it should be clear that
H12 = H11(end) + cumtrapz(TC1(Tm:end),Cp1(Tm:end)-dCp1);
instead of
H12 = cumtrapz(TC1(Tm:end),Cp1(Tm:end)-dCp1);

サインインしてコメントする。

回答 (1 件)

Nipun
Nipun 2023 年 12 月 22 日
Hi Anna,
I understand that you are trying to subtract a constant or provide an offset to summation expression similar to the set of the equations provided.
Having gone through the attached code, it is difficult to infer the reason to the discountinuity due to lack of modelling data.
However, it is evident from the set of expressions that the following line should be mended:
H12 = cumtrapz(TC1(Tm:end),Cp1(Tm:end)-dCp1);
Consider rewriting the code to include the offset outside of the function, like:
H12 = H11(end) + cumtrapz(TC1(Tm:end),Cp1(Tm:end)-dCp1);
Hope this helps.
Regards,
Nipun

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by