想用MATLAB画这样的一个图应如何实现呢?

如题所述

如果只是这个图的话,帮你编了一下代码,力求形似。你再想画别的图,可以在此基础上自由发挥。

clear all;

clc;

t=0:pi/36:2*pi;

x1=30+15*cos(t);y1=30+15*sin(t);z1=15*ones(1,length(t)); %上层外侧

x2=30+10*cos(t);y2=30+10*sin(t);z2=10*ones(1,length(t)); %中层圆

x3=30+5*cos(t);y3=30+5*sin(t);z3=5*ones(1,length(t)); %下层圆

x4=30+10*cos(t);y4=30+10*sin(t);z4=15*ones(1,length(t)); %上层中间圆

x5=30+5*cos(t);y5=30+5*sin(t);z5=15*ones(1,length(t)); %上层内侧圆

t1=0:pi/7:2*pi;

x6=[30+15*cos(t1);30*ones(1,length(t1))];%上层圆半径x值

y6=[30+15*sin(t1);30*ones(1,length(t1))];%上层圆半径y值

z6=[15*ones(1,length(t1));15*ones(1,length(t1))];%上层圆半径z值

A1=[30 45 15]'; B1=[30 15 15]';O=[30 30 0]';line1=[A1,O,B1]; %外侧圆两条直线

A2=[30 40 15]'; B2=[30 20 15]';line2=[A2,O,B2];%中间圆两条直线

A3=[30 35 15]'; B3=[30 25 15]';line3=[A3,O,B3];%内侧圆两条直线

A4=[30 30 15]';line4=[A4,O];%圆心连线

line5=[30 30 30 30 40 30 20;20 30 40 30 30 30 30;10 10 10 10 10 10 10];%中层圆半径

axis1=[20 0 0; 0 0 0;0 20 0;0 0 0; 0 0 20]'; %坐标轴

plot3(x1,y1,z1,'k')

axis([0 50 0 50 0 50])

axis square off

set(gcf,'color','w')

view(102,8)

hold on

plot3(x2,y2,z2,'k')

plot3(x3,y3,z3,'k')

plot3(x4,y4,z4,'k')

plot3(x5,y5,z5,'k')

plot3(x6,y6,z6,'k')

plot3(line1(1,:),line1(2,:),line1(3,:),'k')

plot3(line2(1,:),line2(2,:),line2(3,:),'k')

plot3(line3(1,:),line3(2,:),line3(3,:),'k')

plot3(line4(1,:),line4(2,:),line4(3,:),'k')

plot3(line5(1,:),line5(2,:),line5(3,:),'k')

plot3(axis1(1,:),axis1(2,:),axis1(3,:),'k')

温馨提示:答案为网友推荐,仅供参考
第1个回答  2021-05-20

本视频展示如何用matlab绘制散圆状态图,可用于相关科研数据绘图!

相似回答