Subscript indices must either be real positive integers or logicals - quick question on how to fix
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Numeric Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!