필터 지우기
필터 지우기

Data type converts from integer to array

조회 수: 1 (최근 30일)
Eric Lopez
Eric Lopez 2023년 10월 19일
댓글: Eric Lopez 2023년 10월 19일
When I run the code below, I get an error that the index is not an integer value. Instead, my variable 'r' goes from being an integer to a 1x24 array. Why is this?
--------------------------------------------------------------
R = 1:0.25:6.75;
r = 1;
p = 0;
pout = 0;
Rn = 0;
record = zeros(100, 24);
Pout = zeros(31, 24);
for i = 1:100
for j = 1:24
if r < 6.75
Rn = 4 * r - 3; %Converts ECR to its index
pout = Pout(j, Rn); %Retrive's outage probability
p = randi([0 100], 1) / 100;
if p <= pout
r = floor(2 * R) / 4;
else
r = r + 0.25;
end
elseif r == 6.75
Rn = 4 * r - 3; %Converts ECR to its index
pout = Pout(j, Rn); %Retrive's outage probability
p = randi([0 100], 1) / 100;
if p <= pout
r = floor(2 * R) / 4;
end
end
end
record(i, j) = r;
end

채택된 답변

Walter Roberson
Walter Roberson 2023년 10월 19일
Because R is a vector and you have
r = floor(2 * R) / 4;
which uses the vector R and assigns the result to r making r the same size as R ?
  댓글 수: 1
Eric Lopez
Eric Lopez 2023년 10월 19일
Thank you! These little things I just don’t notice enough as I should.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by