Borrar filtros
Borrar filtros

generate 100-element row in matlab

3 visualizaciones (últimos 30 días)
arash rad
arash rad el 30 de Jun. de 2022
Comentada: Adam Danz el 30 de Jun. de 2022
Hello,
Can anyone help me with generating this signal s(n)=cos(0.04*pi*n) with 100 element row in matlab
  1 comentario
Adam Danz
Adam Danz el 30 de Jun. de 2022
What have you tried so far? Sounds like you need to use linspace.

Iniciar sesión para comentar.

Respuesta aceptada

Pratyush Swain
Pratyush Swain el 30 de Jun. de 2022
Hey,
I believe you need to store the values of the function in a vector of 100 elements;
%create evenly spaced input values%
n=linspace(0,50,100);
%s is the vector which shall contain the output values%
s=zeros(1,100);
%calculate and store function values%
for i=1:length(n)
s(i)=cos(0.04*pi*n(i));
end
%plot to realise them%
figure;
plot(n,s);
Hope this helps.
  1 comentario
Adam Danz
Adam Danz el 30 de Jun. de 2022
In this case, vectorization would be more efficient and readable.
n = linspace(0,50,100);
s = cos(0.04*pi*n);
plot(n,s)

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by