Error: "Array indices must have positive or logical values"
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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.
Risposte (1)
Walter Roberson
il 30 Mar 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 Commenti
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!