Subscript indices must either be real positive integers or logicals - quick question on how to fix
이전 댓글 표시
Greetings all,
I have the following code:
Response_values_H= 0:0.01:9;
R_h=zeros(size(Response_values_H));
for n=1:length(Response_values_H)
rValue_H = Response_values_H(n);
if rValue_H < 9.1
R_h(n)=sqrt(4*rValue_H.^2+1)-2*rValue_H;
else
R_h(n)=0;
end
end
I have a quick question. When I enter an integer, i.e. R_h(25), it returns output. But when I try and enter a decimal, say R_h(2.5), I get: Subscript indices must either be real positive integers or logicals.
So, I tried using round(), but I want to input a decimal. This may be a simple solution, but how can I input a decimal without getting an error? Is there any way to fix it knowing the input must be a decimal?
Thanks! -J
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
