24小时热门版块排行榜    

查看: 1741  |  回复: 1

JESLoooo

新虫 (初入文坛)

[求助] matlab中quiver3和surfnorm的问题 已有1人参与

代码是matlab quiver3函数中的一个例子。输出的图中蓝色矢量是quiver3的结果。然后红色线是另外画的,是surfnorm(x,y,z)的结果。不明白为什么会不一样,surfnorm不就是画出曲面法线的函数么?

matlab中quiver3和surfnorm的问题
91ef76c6a7efce1b1efcfc13a651f3deb58f6517.jpg


matlab中quiver3和surfnorm的问题-1
c2fdfc039245d688176e857dadc27d1ed31b24fe.jpg
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

pdl9527

专家顾问 (小有名气)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★
感谢参与,应助指数 +1
jjdg: 金币+2, 感谢参与 2017-04-05 16:16:49
JESLoooo: 金币+8, ★★★★★最佳答案 2017-04-05 22:50:21
简单点说是横宽比的问题,两次绘图的横宽比不同所以导致视觉上的不一致,以下是转载的解释。

https://nl.mathworks.com/matlabcentral/answers/100252-why-do-the-surface-norms-calculated-by-surfnorm-and-quiver3-not-coincide-in-matlab-6-5-r13

This is the correct behavior. A unit vector only displays orientation information. The orientation needs to be scaled if the aspect ratio is not the basic [1 1 1] as is in the case of an arbitrary plot. Another way to see this is to think of a line going from [0,1] to [1,1]. Imagine plotting the line in different aspect ratios–the unit vector would have to change to stay normal.

To correct the perceived misalignment with SURFNORM and QUIVER3, you can set both the DataAspectRatio and PlotBoxAspectRatio properties of the Axes Object as shown in the following example code:
CODE:
function question_35
clear;clc
[X,Y] = meshgrid(-2:0.25:2,-1:0.2:1);
Z = X.* exp(-X.^2 - Y.^2);
[U,V,W] = surfnorm(X,Y,Z);
quiver3(X,Y,Z,U,V,W,0.5);
hold on
surf(X,Y,Z);
set(gca,'DataAspectRatio',[1 1 1]);% set data aspect ratio
set(gca,'PlotBoxAspectRatio',[1 1 1]);% set plot box aspect ratio
surfnorm(X,Y,Z);
hold off

2楼2017-04-05 16:11:04
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 JESLoooo 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[公派出国] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +3 TxdNP2oT1Q0A 2026-11-21 3/150 2026-11-22 19:54 by EFrqTWPNvJJu
[论文投稿] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +3 TxdNP2oT1Q0A 2026-11-21 4/200 2026-11-22 19:44 by 4xQThdVkmqn8
[博后之家] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +3 Gt0XhENGW3Q3 2026-11-21 3/150 2026-11-22 19:00 by 4xQThdVkmqn8
[论文投稿] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +3 Gt0XhENGW3Q3 2026-11-21 5/250 2026-11-22 18:37 by 4xQThdVkmqn8
[公派出国] 售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急 +4 Gt0XhENGW3Q3 2026-11-21 5/250 2026-11-22 18:16 by 4xQThdVkmqn8
[博后之家] 售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急 +3 YpGmINmR5fp3 2026-11-21 4/200 2026-11-22 18:04 by 4xQThdVkmqn8
[公派出国] 售SCI一区T0P文章,我:8.O.55.1.O54,科目全,可伽急 +4 YpGmINmR5fp3 2026-11-21 4/200 2026-11-22 18:04 by 4xQThdVkmqn8
[基金申请] 售SCI一区文章,我:8.O.551.O.5.4,科目全,可伽急 +5 YpGmINmR5fp3 2026-11-21 6/300 2026-11-22 17:54 by 4xQThdVkmqn8
[考研] 售SCI文章,我:8O.5.5.1O.54,科目全,可十急 +5 YpGmINmR5fp3 2026-11-21 5/250 2026-11-22 17:32 by 4xQThdVkmqn8
[硕博家园] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +3 YpGmINmR5fp3 2026-11-21 3/150 2026-11-22 17:31 by 4xQThdVkmqn8
[基金申请] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +3 K2uSGhxsSAvH 2026-11-21 3/150 2026-11-22 17:20 by 4xQThdVkmqn8
[硕博家园] 售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急 +3 K2uSGhxsSAvH 2026-11-21 3/150 2026-11-22 17:09 by 4xQThdVkmqn8
[论文投稿] 售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急 +6 Xoz0hXWi9tT1 2026-11-21 7/350 2026-11-22 16:26 by 4xQThdVkmqn8
[基金申请] 售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急 +4 Xoz0hXWi9tT1 2026-11-21 5/250 2026-11-22 16:25 by 4xQThdVkmqn8
[考研] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +4 Xoz0hXWi9tT1 2026-11-21 7/350 2026-11-22 16:15 by 4xQThdVkmqn8
[考研] 售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急 +4 Xoz0hXWi9tT1 2026-11-20 5/250 2026-11-22 16:03 by 4xQThdVkmqn8
[找工作] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +4 YpGmINmR5fp3 2026-11-21 5/250 2026-11-22 11:06 by HAlUgI97lcPc
[论文投稿] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +3 YpGmINmR5fp3 2026-11-21 3/150 2026-11-22 10:33 by HAlUgI97lcPc
[考博] 售一区SCI文章T0P,我:8O.551.O54,科目全,可十急 +4 Xoz0hXWi9tT1 2026-11-21 6/300 2026-11-22 09:05 by HAlUgI97lcPc
[公派出国] 售SCI一区文章,我:8.O.551.O.5.4,科目全,可伽急 +3 Xoz0hXWi9tT1 2026-11-21 4/200 2026-11-22 03:46 by mNjrFMLoQVIW
信息提示
请填处理意见