Effacer les filtres
Effacer les filtres

Create a matrix that contains sine wave

23 vues (au cours des 30 derniers jours)
Mohammed Magdy Sharara
Mohammed Magdy Sharara le 22 Oct 2018

Define a 5xN matrix such that each row of the matrix contains a sine wave with a frequency equal to the row number. (0 < t < 1).

I am doing the matrix of zeros thingie but it keeps telling me an error

t=0:0.001:1; x=zeros(5,length(t)); for i=1:length(t) x(i)=sin(2.*pi.*i.*t) end

can any body help ?

Réponses (2)

Erivelton Gualter
Erivelton Gualter le 22 Oct 2018
Try this:
t=0:0.001:1;
x=zeros(5,length(t));
for fi=1:5
for i=1:length(t)
x(fi,i)=sin(2*pi*fi*t(i));
end
end
  1 commentaire
madhan ravi
madhan ravi le 22 Oct 2018
+1 vote crystal clear @Erivelton

Connectez-vous pour commenter.


Akira Agata
Akira Agata le 22 Oct 2018
You can avoid for-loop by simply:
t = 0:0.001:1;
f = 1:5;
x = sin(2*pi*f'*t);

Catégories

En savoir plus sur Crystals dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by