24小时热门版块排行榜    

查看: 1693  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 初试 317 +3 半拉月丙 2026-03-20 3/150 2026-03-21 13:25 by zhukairuo
[考研] 330求调剂0854 +3 assdll 2026-03-21 3/150 2026-03-21 13:01 by 搏击518
[考研] 299求调剂 +4 shxchem 2026-03-20 6/300 2026-03-21 11:54 by 无际的草原
[考研] 0856材料专硕353求调剂 +3 NIFFFfff 2026-03-20 3/150 2026-03-21 10:23 by luoyongfeng
[考研] 材料学学硕080502 337求调剂-一志愿华中科技大学 +4 顺顺顺mr 2026-03-18 5/250 2026-03-21 10:22 by luoyongfeng
[考研] 一志愿重庆大学085700资源与环境总分308求调剂 +6 墨墨漠 2026-03-20 6/300 2026-03-21 09:23 by 天青等烟雨
[考研] 南昌大学材料专硕311分求调剂 +6 77chaselx 2026-03-20 6/300 2026-03-21 07:24 by JourneyLucky
[考研] 求调剂 +3 Ma_xt 2026-03-17 3/150 2026-03-21 02:05 by JourneyLucky
[考研] 278求调剂 +6 烟火先于春 2026-03-17 6/300 2026-03-21 01:57 by JourneyLucky
[考研] 274求调剂 +10 S.H1 2026-03-18 10/500 2026-03-20 23:51 by JourneyLucky
[考研] 304求调剂 +7 司空. 2026-03-18 7/350 2026-03-20 23:08 by JourneyLucky
[考研] 一志愿武理材料工程348求调剂 +3  ̄^ ̄゜汗 2026-03-19 4/200 2026-03-20 21:01 by zhukairuo
[考研] 广西大学家禽遗传育种课题组2026年硕士招生(接收计算机专业调剂) +3 123阿标 2026-03-17 3/150 2026-03-20 15:58 by 飞行琦
[考研] 281求调剂(0805) +14 烟汐忆海 2026-03-16 25/1250 2026-03-20 15:47 by yuncha
[考研] 0703化学调剂 +5 pupcoco 2026-03-17 8/400 2026-03-19 13:58 by houyaoxu
[考研] 344求调剂 +6 knight344 2026-03-16 7/350 2026-03-18 20:13 by walc
[考研] 【同济软件】软件(085405)考研求调剂 +3 2026eternal 2026-03-18 3/150 2026-03-18 19:09 by 搏击518
[考研] 312求调剂 +8 陌宸希 2026-03-16 9/450 2026-03-18 12:39 by Linda Hu
[考研] 308求调剂 +4 是Lupa啊 2026-03-16 4/200 2026-03-17 17:12 by ruiyingmiao
[考研] 一志愿211 0703方向310分求调剂 +3 努力奋斗112 2026-03-15 3/150 2026-03-16 16:44 by houyaoxu
信息提示
请填处理意见