matlab或Origin四维图怎么画(三维坐标+颜色值)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了matlab或Origin四维图怎么画(三维坐标+颜色值)相关的知识,希望对你有一定的参考价值。

参考技术A

用scatter3。

具体请看一下该函数的帮助,举的例子就是类似的用途,如下:

[x,y,z] = sphere(16);

X = [x(:)*.5 x(:)*.75 x(:)];

Y = [y(:)*.5 y(:)*.75 y(:)];

Z = [z(:)*.5 z(:)*.75 z(:)];

S = repmat([1 .75 .5]*10,prod(size(x)),1);

C = repmat([1 2 3],prod(size(x)),1);

scatter3(X(:),Y(:),Z(:),S(:),C(:),'filled'), view(-60,60)

扩展资料:

Matlab包含控制语句、函数、数据结构、输入和输出和面向对象编程特点。用户可以在命令窗口中将输入语句与执行命令同步,也可以先编写好一个较大的复杂的应用程序(M文件)后再一起运行。新版本的MATLAB语言是基于最为流行的C++语言基础上的,因此语法特征与C++语言极为相似,而且更加简单,更加符合科技人员对数学表达式的书写格式。

使之更利于非计算机专业的科技人员使用。而且这种语言可移植性好、可拓展性极强,这也是MATLAB能够深入到科学研究及工程计算各个领域的重要原因。

参考资料来源:百度百科-MATLAB

    官方服务
      官方网站官方网站

matlab画三维空间劣弧,matlab 三维空间画图总结

matlab 三维画图总结

1.画函数的三维图,如:Z(X,Y)=2*X.*exp(-X.^2-Y.^2)+1;

close all;

[X,Y]=meshgrid(-2:0.5:2,-2:0.5:2);%生成坐标轴

Z=2*X.*exp(-X.^2-Y.^2)+1;%Z是X,Y的函数

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

num=0;

num=num+1;

subplot(2,3,num);

plot3(X,Y,Z);

axis([-3 3 -3 3 0 2]);%限定显示的范围

xlabel('x轴');%x轴坐标

ylabel('y轴');%y轴坐标

zlabel('z轴');%z轴坐标

title('http://blog.csdn.net/nuptboyzhb/ figure(1)');%标题

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

num=num+1;

subplot(2,3,num);

mesh(X,Y,Z);

axis([-3 3 -3 3 0 2]);%限定显示的范围

xlabel('x轴');%x轴坐标

ylabel('y轴');%y轴坐标

zlabel('z轴');%z轴坐标

title('http://blog.csdn.net/nuptboyzhb/ figure(2)');%标题

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

num=num+1;

subplot(2,3,num);

meshc(X,Y,Z);

axis([-3 3 -3 3 0 2]);%限定显示的范围

xlabel('x轴');%x轴坐标

ylabel('y轴');%y轴坐标

zlabel('z轴');%z轴坐标

title('http://blog.csdn.net/nuptboyzhb/ figure(3)');%标题

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

num=num+1;

subplot(2,3,num);

surf(X,Y,Z);

axis([-3 3 -3 3 0 2]);%限定显示的范围

xlabel('x轴');%x轴坐标

ylabel('y轴');%y轴坐标

zlabel('z轴');%z轴坐标

title('http://blog.csdn.net/nuptboyzhb/ figure(4)');%标题

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

num=num+1;

subplot(2,3,num);

meshz(X,Y,Z);

axis([-3 3 -3 3 0 2]);%限定显示的范围

xlabel('x轴');%x轴坐标

ylabel('y轴');%y轴坐标

zlabel('z轴');%z轴坐标

title('http://blog.csdn.net/nuptboyzhb/ figure(5)');%标题

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

num=num+1;

subplot(2,3,num);

surf(X,Y,Z);

hold on;

stem3(X,Y,Z,'r');%画竖线

axis([-3 3 -3 3 0 2]);%限定显示的范围

xlabel('x轴');%x轴坐标

ylabel('y轴');%y轴坐标

zlabel('z轴');%z轴坐标

title('http://blog.csdn.net/nuptboyzhb/ figure(6)');%标题

2.画矩阵的三维图

clc;

clear all;

close all;

X=[0 1 2 3 4 5 6 7 8 9];

Y=[0 1 2 3 4 5 6 7 8 9];

for i=1:1:length(X)

for j=1:1:length(Y)

Z(i,j)=mod(i*j*rand(1),9);

end

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

num=0;

num=num+1;

subplot(2,3,num);

plot3(X,Y,Z);

axis([0 9 0 9 0 9]);%限定显示的范围

xlabel('x轴');%x轴坐标

ylabel('y轴');%y轴坐标

zlabel('z轴');%z轴坐标

title('http://blog.csdn.net/nuptboyzhb/ figure(1)');%标题

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

num=num+1;

subplot(2,3,num);

mesh(X,Y,Z);

axis([0 9 0 9 0 9]);%限定显示的范围

xlabel('x轴');%x轴坐标

ylabel('y轴');%y轴坐标

zlabel('z轴');%z轴坐标

title('http://blog.csdn.net/nuptboyzhb/ figure(2)');%标题

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

num=num+1;

subplot(2,3,num);

meshc(X,Y,Z);

axis([0 9 0 9 0 9]);%限定显示的范围

xlabel('x轴');%x轴坐标

ylabel('y轴');%y轴坐标

zlabel('z轴');%z轴坐标

title('http://blog.csdn.net/nuptboyzhb/ figure(3)');%标题

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

num=num+1;

subplot(2,3,num);

surf(X,Y,Z);

axis([0 9 0 9 0 9]);%限定显示的范围

xlabel('x轴');%x轴坐标

ylabel('y轴');%y轴坐标

zlabel('z轴');%z轴坐标

title('http://blog.csdn.net/nuptboyzhb/ figure(4)');%标题

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

num=num+1;

subplot(2,3,num);

meshz(X,Y,Z);

axis([0 9 0 9 0 9]);%限定显示的范围

xlabel('x轴');%x轴坐标

ylabel('y轴');%y轴坐标

zlabel('z轴');%z轴坐标

title('http://blog.csdn.net/nuptboyzhb/ figure(5)');%标题

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

num=num+1;

subplot(2,3,num);

surf(X,Y,Z);

hold on;

stem3(X,Y,Z,'r');%画竖线

axis([0 9 0 9 0 9]);%限定显示的范围

xlabel('x轴');%x轴坐标

ylabel('y轴');%y轴坐标

zlabel('z轴');%z轴坐标

title('http://blog.csdn.net/nuptboyzhb/ figure(6)');%标题

3.画矩阵的颜色深度图

我自己编写的一个函数:graycolor.m

%filename:graycolor.m

%郑海波 2013-01-31

%http://blog.csdn.net/nuptboyzhb/

%原理:灰度图像的伪彩色处理

%值越大,显示的颜色越蓝,越小,显示的颜色越红!

%参数:newbuf必须使二维数组或矩阵

function graycolor(newbuf);

min_n=min(min(newbuf));

max_n=max(max(newbuf));

newbuf=newbuf./(max_n-min_n)*255;

[M N]=size(newbuf);

for i=1:1:M

for j=1:1:N

R(i,j)=GrayColorR(newbuf(i,j));

G(i,j)=GrayColorG(newbuf(i,j));

B(i,j)=GrayColorB(newbuf(i,j));

end

end

img(1:1:M,1:1:N,1)=R(1:M,1:N);

img(1:1:M,1:1:N,2)=G(1:M,1:N);

img(1:1:M,1:1:N,3)=B(1:M,1:N);

imshow(uint8(img));

function r=GrayColorR(gray)

r=0;

if gray>=170

r=255;

end

if gray>=128&&gray<=170

r=255/42*(gray-128);

end

return;

function g=GrayColorG(gray)

g=0;

if gray>=84&&gray<=170

g=255;

end

if gray<=84

g=255/84*gray;

end

if gray>=170&&gray<=255

g=255/85*(255-gray);

end

return;

function b=GrayColorB(gray)

b=0;

if gray<=84

b=255;

end

if gray>=84&&gray<=128

b=255/44*(128-gray);

end

return;

函数的调用:

[X,Y]=meshgrid(-2:0.01:2,-2:0.01:2);%生成坐标轴

Z=2*X.*exp(-X.^2-Y.^2)+1;%Z是X,Y的函数

graycolor(Z);

title('http://blog.csdn.net/nuptboyzhb/');%标题

另外,在\\matlab2009a\\toolbox\\matlab\\demos\\graf3d.m中文件,有更加详细的介绍。界面如下:

以上是关于matlab或Origin四维图怎么画(三维坐标+颜色值)的主要内容,如果未能解决你的问题,请参考以下文章

Origin如何进行三维图绘制

如何使用matlab画三维坐标系

如何用origin画如图所示的三维曲线?

如何用matlab画一个动态图?

如何用origin画3d曲线图

怎样用origin画出三维图