Hello and welcome to beautiful MATLAB 实验室.

把弧度转化为角度

Matlab绘制三角函数是以弧度作为自变量的,这也是所有高级语言采用的共同方法。下面是一个例子:

在命令行中输入:

x=0:pi/100:2*pi;

plot(x,sin(x));

可以得到0~2π区间内sinx的函数图像,可是这个图像横坐标是弧度形式。对于读者来说更希望看到的是角度表示的横坐标。下面的方法可以实现转换:

图1是曲柄滑块机构的滑块位移随曲柄转角变化的曲线,可以看到横坐标是以弧度来表示的。现在我们进行转换,进入Figure编辑器——>点击show plot tool按钮(见图2)——>点击Ticks...(见图2)——>在图3界面里为弧度加上相应的角度——>效果图(见图5)

滑块位移曲线1

图 1

09-12-2007 11_23 下午

图 2

fig2

图 3

滑块位移曲线2

图 4

[ratings]

Posted on 12 九月 '07 by Chan_hwa, under Matlab, Matlab图形图像, Matlab基础. No Comments.

使您输出的maltab图像更具有可读性

我们不仅需要plot命令来显示数据,有时我们甚至需要把图像最重要的部分突出显示给图像的读者。ShadePlotForEmphasis(目标另存为)帮我们做到了这一点。你可以用以下代码进行检验:

% DEFINE DATA
P=[ ...
98 98 94 91 84 83 82 87 88 89 91 91 90 89 89 90 91 91 87 86 87 84 79 80 ...
85 86 86 85 93 93 93 93 97 97 95 93 93 94 95 96 96 92 89 90 91 91 91 92 ...
93 95 99 98 99 97 95 95 94 90 92 93 93 95 94 95 93 92 92 92 91 90 89 89 ...
90 89 90 89 88 84 84 83 84 85 85 84 82 82 82 79 80 79 80 78 78 81 83 82 ...
81 79 77 77 78 77 78 79 79 81 81 81 78 78 78 78 77 78 79 79 79 79 81 85 ...
86 86 86 87 85 84 85 86 88 88 90 88 88 87 86 86 85 87 87 87 86 85 84 83 ...
82 81 81 82 81 80 82 81 79 80 81 80 80 79 85 85 82 83 84 85 86 87 86 86 ...
85 85 85 83 79 81 83 83 84 82 80 80 80 80 84 81 80 76 71 70 70 69 69 68 ...
67 68 68 68 67 68 68 70 70 72 72 71 69 68 68 68 67 68 67 66 67 67 67 66 ...
65 66 65 62 60 60 59 59 59 59 65 66 63 65 68 68 68 68 69 73 74 71 71 69 ...
71 72 72 76 76 74 77 80 82 80 78 80 80 80 80 81 80 79 77];
T=today-length(P)+1:today;
Y={today-[13 74],today-[142 172]};
G={today-[30 51]};
% PLOT THE DATA
plot(T,P);
datetick;
line(get(gca,'Xlim'),[80 80])
line(get(gca,'Xlim'),[68 68])%
title({'ShadePlotForEmphasis','(P<80 yellow, P<68 green)'});
% DRAW SOME YELLOW BARS
ShadePlotForEmpahsis(Y,'y',0.5);
% DRAW A GREEN BAR
ShadePlotForEmpahsis(G,'g',0.5);

shading

[Source from: Doug’s Pick of the Week]

[ratings]

Posted on 18 八月 '07 by Chan_hwa, under Matlab, Matlab图形图像. No Comments.