plotting graph including sigma

1 回表示 (過去 30 日間)
Sojung Park
Sojung Park 2023 年 3 月 12 日
コメント済み: Sojung Park 2023 年 3 月 15 日
I am trying to plot this equation.
I have the values of B, omega_d, zeta, N_k and t_j is the multiples of 1.89.
Below is what I tried but the plot is weird and I can't find what's wrong.
Any comment will be helpfull. Thanks!
B_n=-5.36 ;
omega_d= 400;
zeta=29 ;
N_k=10;
sum=0;
for i=1:N_k
t_j= 1.89.*i;
sum= sum+ exp(-(zeta/2).*(t-t_j)).*(-zeta*(sin(omega_d/2.*(t-t_j)))+ omega_d.*cos(omega_d/2*(t-t_j)));
end
sum=B_n/omega_d.*sum;
t=0:10;
plot(t,sum)
  2 件のコメント
Walter Roberson
Walter Roberson 2023 年 3 月 12 日
We recommend against using sum as the name of a variable, as it is very common to find that in the same code one also needs to use sum as the name of a function.
Walter Roberson
Walter Roberson 2023 年 3 月 12 日
t is not defined in this code.

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

採用された回答

Walter Roberson
Walter Roberson 2023 年 3 月 12 日
Your total is pretty large at small times, and by comparison decays to nothing. This behaviour continues, with large oscillations that dampen quickly relative to earlier values
syms t
Q = @(v) sym(v);
B_n = Q(-536)/100;
omega_d = Q(400);
zeta = Q(29);
N_k = 10;
parts = zeros(1, N_k, 'sym');
for i=1:N_k
t_j= 1.89.*i;
parts(i) = exp(-(zeta/2).*(t-t_j)).*(-zeta*(sin(omega_d/2.*(t-t_j)))+ omega_d.*cos(omega_d/2*(t-t_j)));
end
total = B_n/omega_d.*sum(parts);
fplot(total, [0 2])
fplot(total, [8 10])
  1 件のコメント
Sojung Park
Sojung Park 2023 年 3 月 15 日
Thank you so much!
I have an extra question. How can I change this code if there is a relation between N_k, t, t_j. The relation is that N_k is the integer of t/tt.(when I define t_j=tt*N_k)
I'm confused how I can get the each value when t is changing within the range and apply the effects on the other components.(I tried 'while' and 'if' but I got a warning messege 'Operands to the logical and (&&) and or (||) operators must be convertible to logical scalar values.')

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by