Trying to plot steady state, transient, total response but I can't seem to get it to work.
23 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Case 1
clc
clear all
%%Initial Conditions
zeta = 0.05;
r = 0.3;
naturalfreq = 3.198;
dampfreq = 3.194;
phi = 0.033;
X = 0.048;
omega = 0.96;
Xinitial = 0.048;
phizero = 0.0599;
%%Inputting time
for t = 1:2:20
transient(t) = Xinitial*exp(-zeta*naturalfreq*t)*cos((dampfreq*t)-phizero);
steadystate(t) = X*cos((omega*t)-phi);
total(t) = Xinitial*exp(-zeta*naturalfreq*t)*cos((dampfreq*t)-phizero) + X*cos((omega*t)-phi);
end
time = [1:19];
%%Plot
plot(time,transient,'k');
hold on
plot(time,steadystate,'b');
hold on
plot(time,total,'r');
legend('Transient','Steady State','Total');
xlabel('Time');
ylabel('Response');
title('Case I');
This is the code I'm using and I'm trying to graph to transient, steady state, total response with 10 time periods. It's suppose to look like a sinusoidal graph and similar to what this code produces. However, my code produces it in a triangle like shape when it should be curves.
I tried to solve it by trying to make more points from the for loop but I can't do 1:0.5:20 or something similar because it won't let me index non whole numbers. I'm completely lost on how I should approach this problem any help or suggestion would be greatly appreciated!
0 Kommentare
Antworten (1)
A Jenkins
am 9 Mai 2014
%%Initial Conditions
zeta = 0.05;
r = 0.3;
naturalfreq = 3.198;
dampfreq = 3.194;
phi = 0.033;
X = 0.048;
omega = 0.96;
Xinitial = 0.048;
phizero = 0.0599;
%%Inputting time
idx=1;
time = [1:.01:20];
for t = time
transient(idx) = Xinitial*exp(-zeta*naturalfreq*t)*cos((dampfreq*t)-phizero);
steadystate(idx) = X*cos((omega*t)-phi);
total(idx) = Xinitial*exp(-zeta*naturalfreq*t)*cos((dampfreq*t)-phizero) + X*cos((omega*t)-phi);
idx=idx+1;
end
%%Plot
plot(time,transient,'k');
hold on
plot(time,steadystate,'b');
hold on
plot(time,total,'r');
legend('Transient','Steady State','Total');
xlabel('Time');
ylabel('Response');
title('Case I');
0 Kommentare
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!