Diagonal cross section of function z(x,y) for x=y

조회 수: 2 (최근 30일)
Leia
Leia 2022년 3월 12일
답변: Simon Chan 2022년 3월 12일
I have a function as z(x,y) and I want to plot z(x,y) vs x=y. How can I plot it? Cross section of function z(x,y) for x=y
I will be glad if you help
  댓글 수: 1
DGM
DGM 2022년 3월 12일
How is the function defined? is it a MATAB function? Is this using symbolic tools? Or is it just a 2D numeric array?

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

채택된 답변

Leia
Leia 2022년 3월 12일
t = X-Y;
er = 1e-10;
mask = abs(t) < er;
X2 = X(mask);
Y2 = Y(mask);
Z2 = V(mask);
plot(X2,Y2,Z2)
plot(X2,Z2)

추가 답변 (2개)

Matt J
Matt J 2022년 3월 12일
편집: Matt J 2022년 3월 12일
fcn=@(t) arrayfun(@(x) z(x,x), t);
fplot(fcn)
  댓글 수: 1
Matt J
Matt J 2022년 3월 12일
편집: Matt J 2022년 3월 12일
As an example,
z=@(x,y) x.^2+2*x*y + y.^2;
fcn=@(t) arrayfun(@(x) z(x,x), t);
fplot(fcn,[-1,1])

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


Simon Chan
Simon Chan 2022년 3월 12일
Easier to assign some values where x=y in function meshgrid as follows:
If the assigned values for x and y are different, then the following does not work.
x = -10:0.1:10;
y = -10:0.1:10;
A = 1; % Assume A=1
[X, Y] = meshgrid(x, y);
D = 4; T = 0; K=1;
for p = 0:(D-1)
alpha = 2*pi*p/D;
T= T + exp(1i*K*(cos(alpha)*X+sin(alpha)*Y));
end
Z = A*abs(T/D).^2;
plot(X(X==Y),Z(X==Y))

카테고리

Help CenterFile Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by