I have a 2d matrix Ac(yr,j).
I want it to compare each value of it with another 1D array and store the value of array for which absolute minimum is coming.
for yr=1:32,
for j=1:12,
for in=1.5:1:32.5,
actin=Ac(yr,j);
kar(in-0.5)=abs(in-actin);
dab(yr,j)=min(kar(kar>=0));
end
end
end
I’m able to find the least positive value but not the value of in for which it is coming.
You need to call max as shown below in order to get the index instead of the value.
In order to get rid of the nested loops you could try arrayfun. Define the operation to be performed on every array element.
Execute the defined operations.