matlab三维图加上四维,matlab 3D+颜色的四维函数的作图

函数f=f(x,y,z),x,y,z是三维坐标轴,要画的图中要以x,y,z为三个轴,尝试用surf(x,y,z,f),出来的表面图是用颜色表示了f的大小,为了更直观一些,能不能同时通过表面起伏来表示f大小呢?

结合之前热心朋友的帮助,写了一个小的测试程序:

[theta,phi]=meshgrid(linspace(0,pi,50),linspace(0,2*pi,50));

z=cos(theta);

x=sin(theta).*cos(phi);

y=sin(theta).*sin(phi);

f=-1*((x.*y).^2+(y.*z).^2+(z.*x).^2);

surf(x,y,z,f)

出来的图一:

然后:

[theta,phi]=meshgrid(linspace(0,pi,50),linspace(0,2*pi,50));

z=cos(theta);

x=sin(theta).*cos(phi);

y=sin(theta).*sin(phi);

f=-1*((x.*y).^2+(y.*z).^2+(z.*x).^2);

surf(sin(theta).*cos(phi).*f,sin(theta).*sin(phi).*f,cos(theta).*f,f)

出来的图2:

我现在遇到的问题  就是

[theta,phi]=meshgrid(0:0.1:2*pi,0:0.1:2*pi);

t=0:0.01:0.62;

z=t.*cos(theta);

x=t.*sin(theta).*cos(phi);

y=t.*sin(theta).*sin(phi);

f=-1*((x.*y).^2+(y.*z).^2+(z.*x).^2);

surf(sin(theta).*cos(phi).*f,sin(theta).*sin(phi).*f,cos(theta).*f,f)

Error using surf (line 75)

Z must be a matrix, not a scalar or vector.rf(sin(theta).*cos(phi).*f,sin(theta).*sin(phi).*f,cos(theta).*f,f)

是不是要用循环来计算啊  怎么样才能让矩阵维数一致呢?  求指导啊

2015-3-4 21:52 上传

442a53943febe9465fc072b4fbe10813.gif

b2a5a3e0dcc7d508e00275fe42fce1b5.gif

图一

1433d4a70a89736dab61a26be2c1b463.png

2015-3-4 21:54 上传

442a53943febe9465fc072b4fbe10813.gif

b2a5a3e0dcc7d508e00275fe42fce1b5.gif

图2

684245a5e715d3f0961aac5851f52281.png

  • 0
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值