extracting data by min and loop

3 次查看(过去 30 天)
Babak MJ
Babak MJ 2016-8-21
I have the topography data in which I introduced X, Y, Z as follows. X and Y is the coordinate and Z is the elevation. I want to extract the min Z for each raw and their X and Y. Since I want to have the min elevation graph based on the distance, I need to calculate [delta(X)^2 + delta(Y)^2] for the Z which are not in the same column. Here is the code which I write, but it doesnt work the way I want!! any idea?
X=[25 26 28];
Y=[50 51 55];
Z = [345 386 312;607 615 630;995 901 956];
nrX=length(X);
nrY=length(Y);
if nrX > nrY;
nrT=nrX;
else
nrT=nrY;
end
[R,I]=min(Z,[],2);
X2=X(I);
Y;
for i=1:nrX-1
for j=1:nrY-1
for k=1:nrT-1
T(k)= ((X2(i+1)-X2(i))^2+(Y(j+1)-Y(j))^2)^0.5
end
end
end
R
T

回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2016-8-21
Z = [345 386 312;607 615 630;995 901 956]
min_val,index=min(Z,[],2)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by