Need help with syntax and how to use sigma in matlab

3 ビュー (過去 30 日間)
Mircea Prisada
Mircea Prisada 2022 年 4 月 25 日
編集済み: VBBV 2022 年 4 月 25 日
I don't know how to type Uan from my code below in matlab. It says ''Matrix dimensions must agree.''
This is what Im trying to type:
clear
close all
Z1=500
Z2=50
Z3=500
u=1
tau1=(2*Z2)/(Z1+Z2);
tau2=(2*Z1)/(Z1+Z2);
tau3=(2*Z3)/(Z3+Z2);
p1=(Z2-Z1)/(Z2+Z1);
p2=(Z1-Z2)/(Z1+Z2);
p3=(Z3-Z2)/(Z3+Z2);
T=2*10^-6
t=0:50*T/200:50*T
%I am stuck on Uan and F1
n=2:3:25
ua1=tau1*u.*(t>=0)
Uan=(tau1.*tau2.*(p3^n-1).*(p2^n-2).*u).*(t>=(n-1)*2*T)
F1=symsum(Uan,n,2,25)
figure(1)
plot(t,F1, 'DisplayName', 'F1')

採用された回答

VBBV
VBBV 2022 年 4 月 25 日
編集済み: VBBV 2022 年 4 月 25 日
clear
close all
Z1=500
Z2=50
Z3=500
u=1
tau1=(2*Z2)/(Z1+Z2)
tau2=(2*Z1)/(Z1+Z2)
tau3=(2*Z3)/(Z3+Z2)
p1=(Z2-Z1)/(Z2+Z1)
p2=(Z1-Z2)/(Z1+Z2)
p3=(Z3-Z2)/(Z3+Z2)
T=2*10^-6
t=0:50*T/200:50*T
%I am stuck on Uan and F1
n=linspace(2,25,length(t)) % change
ua1=tau1*u.*(t>=0)
Uan=(tau1.*tau2.*(p3.^n-1).*(p2.^n-2).*u).*(t>=(n-1)*2*T)
syms n % declare n as symbolic variable
F1=symsum(Uan,n,2,25)
figure(1)
plot(t,F1+ua1, 'DisplayName', 'F1')
Declare n as symbolic variable while using it in symsum. Make the length of vectors n and t equal.

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by