简体   繁体   中英

plotting a rectangle and set of points together in matlab

I am a complete newbie to matlab....As of now I am experimenting with stuff.I wanted to plot a set of points together with a rectangle in matlab.One of my friends told me the following piece of code...It seems to be wrong

clear all; close all;clc;
data = cell2mat({1,1;2,2;3,3;4,4;5,5;6,6;});
xx=data(:,1);
yy=data(:,2);
hand=plot(xx,yy,'r.',Rectangle('Position',[1,1,2,2]));xmin=min(xx);xmax=max(xx);ymin=min(yy);ymax=max(yy);
axis([xmin xmax ymin ymax]);
axis('square');set(hand, 'MarkerSize', 1);

The plot command seems to fail...What is the correction I have to make???

Plot points, hold on additional plots, then plot rectangle:

hand = plot(xx,yy,'r.'); 
hold on 
rectangle('Position',[1,1,2,2]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM