I want to create a sin wave pulse function y(t) that has exponential damping, but I get this error "Array indices must be positive integers"
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Roberto Santana
am 23 Mär. 2022
Kommentiert: Roberto Santana
am 23 Mär. 2022
This is the code I have, Any ideas why I'm getting this error? I am a college student and just started working with matlab
A=4
a=exp(-0.5*t)
y(t)=A*a(sin(2*pi*3*t)).*(ustep(t+1)-ustep(t-1))
t=linspace(-2,2)
y(t)=linspace(-4,4)
plot(y(t))
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 23 Mär. 2022
I don't have the ustep() function, but I think this is closer than what you have:
A = 4
t = linspace(-2, 2, 1000);
a = exp(-0.5*t)
y = A * a * (sin(2*pi*3*t)) .* (ustep(t+1)-ustep(t-1))
plot(t, y, 'LineWidth', 2)
xlabel('t');
ylabel('y');
grid on;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!