Error: "Array indices must have positive or logical values"

1 回表示 (過去 30 日間)
noobmaster69
noobmaster69 2019 年 3 月 30 日
コメント済み: Rena Berman 2019 年 10 月 28 日
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 件のコメント
Rena Berman
Rena Berman 2019 年 10 月 28 日
(Answers Dev) Restored edit

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 3 月 30 日
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

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by