find is not working in a loop, it skips numbers
Hello,
I am using a loop with a "find" to indentify the rows in the third column that have the same number (e.g. 0.75 etc), then I select which to chose based on a criterio. In some cases for example 0.82, 0.93 the function find returns a zero array instead of an array with ones at the locations of the number. Depending on the limits of the initial range ("sisto" in the code below) it skips different number. I tried to correct using the mask instead of the find but I am still having the same results. Could you please help me with this? (I attach the text file with the input matrix) Thanks.
load(‘HP4140AT5OR40DOS.txt’);
LINE=HP4140AT5OR40DOS;
x=LINE(:,3);
sisto = 0.60:0.01:1;
s=size(sisto,2)
for i=1:s
sisto(i)
find = (x==sisto(i));
MA=LINE(find,:)
dast=MA(:,5); %the storage days
ouf=abs(40-dast)% how close they are to 30
[minValue, minIndex] = min(ouf)
point=MA(minIndex,:)%the point I select for this wind contribution
endHello,
I am using a loop with a "find" to indentify the rows in the third column that have the same number (e.g. 0.75 etc), then I select which to chose based on a criterio. In some cases for example 0.82, 0.93 the function find returns a zero array instead of an array with ones at the locations of the number. Depending on the limits of the initial range ("sisto" in the code below) it skips different number. I tried to correct using the mask instead of the find but I am still having the same results. Could you please help me with this? (I attach the text file with the input matrix) Thanks.
load(‘HP4140AT5OR40DOS.txt’);
LINE=HP4140AT5OR40DOS;
x=LINE(:,3);
sisto = 0.60:0.01:1;
s=size(sisto,2)
for i=1:s
sisto(i)
find = (x==sisto(i));
MA=LINE(find,:)
dast=MA(:,5); %the storage days
ouf=abs(40-dast)% how close they are to 30
[minValue, minIndex] = min(ouf)
point=MA(minIndex,:)%the point I select for this wind contribution
end Hello,
I am using a loop with a "find" to indentify the rows in the third column that have the same number (e.g. 0.75 etc), then I select which to chose based on a criterio. In some cases for example 0.82, 0.93 the function find returns a zero array instead of an array with ones at the locations of the number. Depending on the limits of the initial range ("sisto" in the code below) it skips different number. I tried to correct using the mask instead of the find but I am still having the same results. Could you please help me with this? (I attach the text file with the input matrix) Thanks.
load(‘HP4140AT5OR40DOS.txt’);
LINE=HP4140AT5OR40DOS;
x=LINE(:,3);
sisto = 0.60:0.01:1;
s=size(sisto,2)
for i=1:s
sisto(i)
find = (x==sisto(i));
MA=LINE(find,:)
dast=MA(:,5); %the storage days
ouf=abs(40-dast)% how close they are to 30
[minValue, minIndex] = min(ouf)
point=MA(minIndex,:)%the point I select for this wind contribution
end find, loop, skips MATLAB Answers — New Questions