# write a 'for' loop numbers in a single row matrix

3 views (last 30 days)
MOzhdeh Salimi on 28 Aug 2021
Commented: MOzhdeh Salimi on 29 Aug 2021
Hi all
This is my code. I want to write 'Tmax' in one single row matrix.
Please help me.
% read image and fit regression line%
VF = imread('Vf.tif');
Tnormal= imread('Tnormmsh.tif');
[i,j]=size(VF);
length=i*j;
X=VF(1:length);
Y=Tnormal(1:length);
Minx=min(X);
Maxx=max(X);
Miny=min(Y);
Maxy=max(Y);
for x0=Minx:0.01:Maxx
X1=x0;
X2=x0+0.01;
idx= find(X>=X1 & X<X2);
x3=X(idx);
y3=Y(idx);
Tmax=max(y3);
end
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Accepted Answer

Wan Ji on 28 Aug 2021
Hi, MOzhdeh Salimi
Here I donot know your tiff file but I have written code for you!
VF = rand(100,100);
Tnormal = rand(100,100);
[i,j]=size(VF);
length=i*j;
X=VF(1:length);
Y=Tnormal(1:length);
Minx=min(X);
Maxx=max(X);
Miny=min(Y);
Maxy=max(Y);
x0_arr = Minx:0.01:Maxx;
Tmax = zeros(size(x0_arr)); % initialize Tmax
for i = 1:1:numel(x0_arr)
x0 = x0_arr(i);
X1=x0;
X2=x0+0.01;
idx= find(X>=X1 & X<X2);
x3=X(idx);
y3=Y(idx);
Tmax(i)=max(y3); % store it in Tmax
end
##### 1 CommentShowHide None
MOzhdeh Salimi on 29 Aug 2021
Thanks a lot. your code is working very well.

Sign in to comment.

### Categories

Find more on Loops and Conditional Statements 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!