I want to apply a function to each row in a matrix. For example, my function is function(R,L); where R is the input (row) and L is the difference between the max and min value of that R (row). How can I do this program?
I tried this way
MyData=load('file.dat'); %this is a 100x100 matrix
NewMat=zeros(100,100); %create a zero matrix
For i=1:100j=MyData(i,:);L=max(j)-min(j);NewData=function(j,L);end
Now I don't know how to replace the NewData for each 'i' value in the NewMat. My logic here is to create a zero matrix, then apply the function to each row in the original data(NewData), then replace the corresponding row in the zero matrix with the NewData.
Please help me to make this program
Best Answer