Need help with syntax and how to use sigma in matlab
5 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
VBBV
on 25 Apr 2022
Edited: VBBV
on 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 Comments
More Answers (0)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!