I need to use tf() function to create multiple step responses

18 visualizzazioni (ultimi 30 giorni)
I need to use the tf command to comute a function, then graph it using the step command.
I can do this with a set line, however for the equation seen in the attatchment. I have constant values for m & k, the goal is for the code to subsitute c in as a value starting from 0, solve the equation and take a step of 1, then re-solve the equation. This process will continue until the final desired value of c = 20 is used. For each calculation the values should be saved and then compiled on the step graph. Below is the code I wrote, the numerous hold on was my attempt at getting MATLAB to keep the values, unfortunately it did not work. Thank-you for your help
%% Iteration Calculation for fixed DE (Must Edit in Script for Different DE) %%
iteration = 0; % sets iteration counter to 0 %
hold on
while(iteration <= 20) % starting while loop %
iteration = iteration + 1; % Updating Iteration Counter %
hold on;
for Fs1 = tf([1],[1 iteration 25]); % sets tf to update based on iteration value %
hold on;
end
end
hold on;
%% Graphing Fs1 %%
figure (1)
step(Fs1) % Graphs Fs1 %

Risposta accettata

Sam Chak
Sam Chak il 4 Ott 2023
Hi @Kez
I assume you want to create plots of multiple step responses while varying the damping term c.
m = 1;
c = 0:20;
k = 25;
for j = 1:length(c)
Fs1 = tf(1, [m c(j) k]);
step(Fs1, 10)
hold on;
end
hold off

Più risposte (0)

Prodotti


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by