フィルターのクリア

How can I specify the dimension of a differentiated function?

3 ビュー (過去 30 日間)
Ambali Odebowale
Ambali Odebowale 2023 年 1 月 27 日
移動済み: Walter Roberson 2023 年 1 月 27 日
I am getting error when I tried to find h_w_net and the error is "Matrix dimensions must agree" at the last line.
The dimension of k_r=500 by 1, PTC=500 by 500, theta=1 by 500. After I differentiated theta (rep by theta_diff) its dimension is 1 by 200.
How can I make dimension of theta_diff 1 by 500?
Thanks
%Here is the code
T=300;
theta = h_bar*w ./ ( exp( (h_bar*w)/(k_B*T) ) - 1 ) ;
theta_diff=diff(theta,T);
%Thermal conductance calculation
h_w_net= (1/4*pi^2) *theta_diff.* k_r .* PTC ;
  2 件のコメント
Rik
Rik 2023 年 1 月 27 日
Did you really intend to take the 300th derivative? I get the impression you don't really understand what the diff function is doing.
When you put in an array, if will calculate the difference between subsequent values. So it doesn't really find the derivative, as it find the numerical approximation of the derivative on the midpoints.
x = [1 2 3];
y = [7 3 6];
diff(y),corresponding_x=mean([x(1:(end-1)) ; x(2:end)])
ans = 1×2
-4 3
corresponding_x = 1×2
1.5000 2.5000
Ambali Odebowale
Ambali Odebowale 2023 年 1 月 27 日
編集済み: Ambali Odebowale 2023 年 1 月 27 日
No, I want to differentiate the function theta wrt T. Kindly ignore the T value. It's an error on my part

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

回答 (2 件)

Walter Roberson
Walter Roberson 2023 年 1 月 27 日
diff() is generally successive differences. It is only derivative if the first parameter is sym or symfun, both from the Symbolic Toolbox

Ambali Odebowale
Ambali Odebowale 2023 年 1 月 27 日
移動済み: Walter Roberson 2023 年 1 月 27 日
I was able to solve it by using syms
Thanks for your time

カテゴリ

Help Center および File ExchangeFormula Manipulation and Simplification についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by