Help with nested for loop, for a matlab hw problem
Mostra commenti meno recenti
So i've been working on this problem for a while and not really sure what i'm doing, can someone point me in the right direction
this is my code so far
clc
clear all
t=linspace(0,10,500);
omaga_d_1=.5;
omaga_d_2=1.1;
omaga_d_3=1.5;
sigma_d=3.5;
sigma_d_1=5;
for i=1:t;
c=5*exp.^(-omaga_d_1*t).*cos(sigma_d*t);
end
plot(t,c)

Risposte (2)
KSSV
il 18 Ott 2016
clc; clear all ;
t=linspace(0,10,500);
omaga_d=[.5 1.1 1.5 3.5];
sigma_d=5;
c = zeros(length(omaga_d),length(t)) ;
for i = 1:length(omaga_d)
c(i,:)=5*exp(-omaga_d(i)*t).*cos(sigma_d*t);
end
plot(t,c)
sigma_d = [0.5 1.1 1.5];
omega_d = [3.5 5.0];
Put those into arrays to start with (you got them the wrong way round too so far as I can see). Those are then the two arrays you are expected to loop over in your nested for loops.
I'm not going to do the whole question for you because it is homework but that is a step in the right direction.
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!