projecting point on plain
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hey everybody, i have to project points on a plain and then link them, so you can see the distance between them. But i have no clue how to solve that problem. My professor ment, that there is a very easy caommand for it, but i could'nt find anything on the internet. Is there somebody who can help me out with this problem? I'm totally new on Matlab.
thanks in advance MadeMo
if true
% matrix=[6007 8969 96.51
7253 577 100.08
446 7353 101.56
7807 3734 99.98
4256 4681 100.67
606 9631 99.25
5171 4244 100.69
351 3778 105.37
4716 3118 100.09
8542 2541 101.19
2580 2030 101.27
1475 225 102.63
3491 3086 100.23
8053 6564 100.15
9912 4060 102.05
5534 7165 94.86
4636 5979 97.35
4519 2443 98.97
9712 8774 95.31
7124 319 100.46
8406 2296 101.53
4563 8757 96.49
6073 9278 95.99
1876 4615 102.84
6645 9285 95.47
4988 8119 96.42
9510 8479 95.72
1206 7563 101.93
5043 1119 101.04
1623 577 101.89
8284 6259 100.62
6556 2803 103.97
8702 6268 100.18
1578 5826 101.33
6587 9984 94.13
8122 1151 100.37
8741 4196 100.76
429 617 106.28
8811 2249 101.42
5072 5456 97.98
3576 1045 100.81
8539 4781 101.11
8607 3583 99.77
5900 231 101.65
4159 4184 101.12
6489 715 100.95
6987 5192 100.01
6983 8564 97.04
1019 3570 105.68
8548 9140 96.29]
xm=matrix(:,1)
ym=matrix(:,2)
zm=matrix(:,3)
%z(x,y)=u1+u2*x+u3*y+u4*x²+u5*x*y+u6*y²
xquadr=xm.*xm
yquadr=ym.*ym
xy=xm.*ym
A=[ones(size(xm)),xm,ym,xquadr,xy,yquadr]
b=zm
x=A\b
x1=x(1,1)
x2=x(2,1)
x3=x(3,1)
x4=x(4,1)
x5=x(5,1)
x6=x(6,1)
%b)
xpoints=1:100:10000
ypoints=1:100:10000
[meshgridx,meshgridy]=meshgrid(xpoints,ypoints)
meshgridz=x1+x2.*meshgridx+x3.*meshgridy+x4.*meshgridx.*meshgridx+x5.*meshgridx.*meshgridy+x6.*meshgridy.*meshgridy
xlabel ('Kantenlänge a [m]')
ylabel ('Kantenlänge b [m]')
zlabel ('Grundwasserstand [m]')
%c)
mesh(meshgridx,meshgridy,meshgridz)
hold on
scatter3 (xm,ym,zm,'.')
end
2 Kommentare
Antworten (1)
KSSV
am 8 Jun. 2017
clc; clear all;
matrix=[6007 8969 96.51
7253 577 100.08
446 7353 101.56
7807 3734 99.98
4256 4681 100.67
606 9631 99.25
5171 4244 100.69
351 3778 105.37
4716 3118 100.09
8542 2541 101.19
2580 2030 101.27
1475 225 102.63
3491 3086 100.23
8053 6564 100.15
9912 4060 102.05
5534 7165 94.86
4636 5979 97.35
4519 2443 98.97
9712 8774 95.31
7124 319 100.46
8406 2296 101.53
4563 8757 96.49
6073 9278 95.99
1876 4615 102.84
6645 9285 95.47
4988 8119 96.42
9510 8479 95.72
1206 7563 101.93
5043 1119 101.04
1623 577 101.89
8284 6259 100.62
6556 2803 103.97
8702 6268 100.18
1578 5826 101.33
6587 9984 94.13
8122 1151 100.37
8741 4196 100.76
429 617 106.28
8811 2249 101.42
5072 5456 97.98
3576 1045 100.81
8539 4781 101.11
8607 3583 99.77
5900 231 101.65
4159 4184 101.12
6489 715 100.95
6987 5192 100.01
6983 8564 97.04
1019 3570 105.68
8548 9140 96.29] ;
xm=matrix(:,1) ;
ym=matrix(:,2) ;
zm=matrix(:,3) ;
%z(x,y)=u1+u2*x+u3*y+u4*x²+u5*x*y+u6*y²
xquadr=xm.*xm ;
yquadr=ym.*ym ;
xy=xm.*ym ;
A=[ones(size(xm)),xm,ym,xquadr,xy,yquadr] ;
b=zm ;
x=A\b ;
x1=x(1,1) ;
x2=x(2,1) ;
x3=x(3,1) ;
x4=x(4,1) ;
x5=x(5,1) ;
x6=x(6,1) ;
%b)
xpoints=1:100:10000 ;
ypoints=1:100:10000 ;
[meshgridx,meshgridy]=meshgrid(xpoints,ypoints) ;
meshgridz=x1+x2.*meshgridx+x3.*meshgridy+x4.*meshgridx.*meshgridx+x5.*meshgridx.*meshgridy+x6.*meshgridy.*meshgridy ;
xlabel ('Kantenlänge a [m]') ;
ylabel ('Kantenlänge b [m]') ;
zlabel ('Grundwasserstand [m]') ;
%c)
mesh(meshgridx,meshgridy,meshgridz) ;
hold on
scatter3 (xm,ym,zm,'.') ;
%%Get nearest neighbor to draw line
for i = 1:length(xm)
idx = knnsearch([meshgridx(:) meshgridy(:) meshgridz(:)],[xm(i) ym(i) zm(i)]) ;
line([xm(i) meshgridx(idx)],[ym(i) meshgridy(idx)],[zm(i) meshgridz(idx)]) ;
end
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!