4
Good afternoon. Here’s the following, I used the following function to create an empty array that later stores certain values requested from the user:
fragil = zeros(1, 10); %criaçao do vetor
idF = str2double(input('Insira um número inteiro!: ', 's')); % pedido de input
fragil(1,k)=idF; %guarda o valor no vetor
However, when the number of inserted values is less than 10, the array will stay with the remaining values at 0 and then when I try to fetch the values of the array to use in a comparison I have the following error message:
Index in position 2 is invalid. Array indices must be Positive integers or Logical values.
Error in Step 0 (line 40)
if Mcobertura(m,elder)=1
My doubt consists (or not) in two parts: 1- How can I "clear" the null values of positions not used in the vector. 2-If the error message is not associated with this detail, what will be the problem. Then there is the code snippet where the error is identified.
for l=1:k
verificaF=0;
idosoF= fragil(1,l);
for m=1:numAmbulancias
if MCobertura(m,idosoF)==1
verificaF=verificaF+1;
end
end
if verificaF<2
haSolucao=false;
break;
end
In which k corresponds to the number of inputs made by the user, in Ambulatory corresponds to the lines of Mcobertura and aged.