필터 지우기
필터 지우기

How to generate a coordinate field, compute values for each coordinate and plot the results?

조회 수: 1 (최근 30일)
Hello,
first, i would like to generate a 2D coordinate field from e.g. 0/0 to 0/100, 100/100 and 100/0 with 10 steps, giving 11x11 = 121 coordinates.
My first try is:
for i = 0:10
A(:,1+2*i) = 0:10:100;
A(:,2+2*i) = (i)*10;
end
I don't like this solution, especially if I want to calculate larger fields.....
second, i would like to calculate a value for each coordinate, e.g. value = f(x,y). How can i plot the calculated values with its x,y coordinates in a 3D plot?
I would be very grateful for assistance and possible solutions!
Christopher

채택된 답변

KSSV
KSSV 2019년 1월 30일
편집: KSSV 2019년 1월 30일
Read about linspace and meshgrid
x = linspace(0,100,11) ;
y = linspace(0,100,11) ;
[X,Y] = meshgrid(x,y) ;
Z = X+Y ;
surf(X,Y,Z)
  댓글 수: 5
KSSV
KSSV 2019년 1월 30일
Thats striaght forward.....I have given examples above......as you are using matrices ..read about element by element operations in matrices. https://in.mathworks.com/help/fixedpoint/ref/times.html
Christopher Brokmann
Christopher Brokmann 2019년 1월 30일
i still have problems to include my function... the only solution i found is with 2 loops, which has the disadvantage of a long run time epsecially for a high number of points for x and y.
x = linspace(0,1,11) ;
y = linspace(0,1,11) ;
[X,Y] = meshgrid(x,y) ;
for kk = 1:11
for nn = 1:11
Coordinate = [X(kk,nn) Y(kk,nn)];
Z(kk,nn) = f_DeltaWegPunkt(Coordinate,someConstant,...);
end
end

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by