Need help with syntax and how to use sigma in matlab
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mircea Prisada
am 25 Apr. 2022
Bearbeitet: VBBV
am 25 Apr. 2022
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')
0 Kommentare
Akzeptierte Antwort
VBBV
am 25 Apr. 2022
Bearbeitet: VBBV
am 25 Apr. 2022
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Calculus finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!