Why is this "z=x.*exp(-X.^2-Y.^2) " required?
조회 수: 4 (최근 30일)
이전 댓글 표시
[x,y]=meshgrid(-2:.2:2);
z=x.*exp(-X.^2-Y.^2);
why is z=.... required??? and also why is (-X.^2-Y.^2)??
댓글 수: 0
채택된 답변
Walter Roberson
2021년 8월 21일
The z= part is not required. The (-X.^2-Y.^2) part is not required either. However, as long as you have exp() you need to provide some argument to it.
For example, the following would be valid MATLAB code:
[x,y]=meshgrid(-2:.2:2);
x.*exp(-1);
However, it does not do anything useful.
I suspect that you are looking for something closer to
[x, y] = meshgrid(-2:.2:2);
z = x .* exp(-x.^2 - y.^2);
surf(x, y, z, 'edgecolor', 'none')
xlabel('x'); ylabel('y');
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!