For loop execution.

1 visualización (últimos 30 días)
Telema Harry
Telema Harry el 23 de Mzo. de 2021
Comentada: Telema Harry el 23 de Mzo. de 2021
I am trying to compute the code shown below. but keep getting error. I will be happy if someone could please look at the code
clear all;
N = 200;
Fs = 50;
Fo1 = 10;
Fo2 = 60;
ts = 1/Fs;
T = (N - 1)* ts;
A1 = 2;
A2 = 4;
t = 0:ts:T;
B = [0.1:0.1:0.9, 1:0.5:10];
X = zeros (length(B),N);
for m = 1: length(B)
if (B(m) >= 0.1 & B(m) < 1)
for d = 1: N
X(m,d) = A1*sin(2*pi.*(Fo1./B(m)).* t(d)).*( t >= 0.1 & t <= 2.5) + ...
A2* cos(2*pi.*(Fo2./B(m)).* t(d)).*(t>=2.6 & t <4.9);
end
elseif (B(m) >= 1)
for d = 1: N
Sn(m,d) = A1*sin(2*pi.*(Fo1./B(m)).* t(d)).*( t >= 0.1 & t <= 2.5) + ...
A2* cos(2*pi.*(Fo2./B(m)).* t(d)).*(t>=2.6 & t <4.9);
end
end
end

Respuesta aceptada

William
William el 23 de Mzo. de 2021
I think it may be the 4 clauses that read like (t >= 0.1 & t <= 2.5). Shouldn't these say (t(d) >= 0.1 & t(d) <= 2.5)?
  1 comentario
Telema Harry
Telema Harry el 23 de Mzo. de 2021
Problem solved. Thank you so much.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by