How to plot a function with summation and multiple variables?
1 view (last 30 days)
Show older comments
I would like to plot this function. I started writing the code but there are a lot of errors. Any help please!
n=10;
a = 1; %period
t = 0:0.1:1;%time
s=0.1;%area
t0=0.03;%impulse
ti=0.01;%random fluctuation around the average period
for i=1:n
eq(t)=a(i).*s.*(t-i.*t0-ti);
end
eq=sum(eq)
0 Comments
Answers (1)
Ive J
on 24 Oct 2021
Start by understanding MATLAB a bit better. For the time being this may help you:
myfnc = @(A, s, t, i, T0, tau) sum(A.*s.*(t - i.*T0 - tau)); % based on the attached fig, both A and tau should be vectors
n = 10;
A = rand(1, n);
tau = rand(1, n);
s = 0.1;
t = linspace(0, 1, n); % doesn't seem to be a vector in your fig (?)
T0 = 0.03;
myfnc(A, s, t, 1:n, T0, tau)
See Also
Categories
Find more on Multirate Signal Processing 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!