Error: "Array indices must have positive or logical values"
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
close all;
clc;
Tp = .00005;
Bw = 10^8;
P = 1; %Watt
R = 10^3; %m
r = 20*10^9; %sps
t = linspace(0,Tp,(r.*Tp));
Fif = 10^9; %intermediate frequency
g = Bw./Tp; %chirp rate
a = 1; %rectangularPulse((t-.5.*Tp)./Tp);
Xif(t) = a.*cos(2*pi*(Fif-.5*Bw).*t + pi*g*t.^2); %g ="chirp rate"
figure;
plot(t,Xif(t));
That's my code, and I keep getting that error for some reason. I'm not sure how to fix it.
1 comentario
Respuestas (1)
Walter Roberson
el 30 de Mzo. de 2019
You are getting confused between formula and expressions.
When you define Xif(t) = something, you are probably thinking in terms of typical notation for defining a formula -- a statement that for some arbitrary t to be determined later, that what is on the right hand side defines how the value of Xif should be computed.
But in MATLAB, things do not work that way. I recently explained in the bottom half of https://www.mathworks.com/matlabcentral/answers/453312-matlab-error-array-indices-must-be-positive-or-logical-values#answer_368153
0 comentarios
Ver también
Categorías
Más información sobre Multidimensional Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!