简单的MatLab图 [英] Simple MatLab plot

查看:81
本文介绍了简单的MatLab图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是MatLab的初学者,必须绘制(0.5,0.5),(-0.5,0.5),(-0.5,-0.5)和(0.5,-0.5)并在屏幕上画点.到目前为止,这是我输入的代码:

I am a beginner in MatLab and I have to plot (0.5, 0.5), (-0.5, 0.5), (-0.5, -0.5) and (0.5, -0.5) with lines joining the point on the screen. Here is the code I have typed out so far:

function []=strain_rate_tensor(t)
axis([-1 1 -1 1])
hold on
plot(0.5, -0.5, 'b')
hold on
plot(-0.5, -0.5, 'b')
hold on
plot(0.5, 0.5, 'b')
hold on
plot(-0.5, 0.5, 'b')
hold on


运行此脚本时出现空白屏幕.我的情节怎么了?代码是绘制流体包裹,然后对其进行一些变换.


I get a blank screen when I run this script. What is wrong with my plot? The code is to plot a fluid parcel and then apply some transformations on it.

推荐答案

您刚刚绘制了四个点,您可能想要绘制一两条线,或者四颗星或更大的点.

You just plotted four dots, you probably either want to plot one or two lines, or four stars or bigger dots.

请务必检查doc plot以获取有关绘制方式的示例.

Make sure to check doc plot for examples on how to plot.

我想你想要这个:

plot([0.5 -0.5; -0.5 -0.5; 0.5 0.5; -0.5 0.5]','bo-')


旁注:您只需要使用一次Hold(在第一个或第二个绘图之前),并且您可能想要在完成后再次将其关闭.


Sidenote: You only need to use hold on once (before the first or second plot) and you may want to turn it off again after you finish.

这篇关于简单的MatLab图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆