How to use gplot for co-ordinates

I very simply want to use gplot for two vectors (x and y), such that they create 5 co-ordinates.
How do I do this? (syntax-wise)
Thanks a lot

 Réponse acceptée

Dishant Arora
Dishant Arora le 2 Sep 2013

0 votes

gplot(eye(length(x)) , [x' , y'], '*');
% x and y are row vectors containing co-ordinates.

Plus de réponses (1)

Brian
Brian le 2 Sep 2013

0 votes

It says "??? Index exceeds matrix dimensions."
Really don't know what I'm doing wrong.
Thanks for your help

6 commentaires

Dishant Arora
Dishant Arora le 2 Sep 2013
You need to show your piece of code. saying "index exceeds matrix dimensions" wouldn't help. And did you try to debug it
Brian
Brian le 2 Sep 2013
figure; axis([0 15 0 15]); hold on; uiwait(msgbox('click 5 points in the figure to fit a curve through')); [x, y] = ginput(5); plot(x,y,'x');
f=[x';1,1,1,1,1]'
a=inv(f'*f)*f'*y
t= [0:0.01:15]; b=a([1],:) d=a([2],:) c=(b + d*t); figure; axis([0 15 0 15]); hold on; plot(x,y,t,c)
gplot(eye(length(x)) , [x' , y'], '*');
How do I debug it?
Dishant Arora
Dishant Arora le 2 Sep 2013
As I said earlier in my answer x and y were row vectors but in your case ginput returns x and y as column vectors. you need to take care of that .
Brian
Brian le 2 Sep 2013
It draws from one point to another, I want each point to connect to each other, how do I do this?
Thanks
(this is the current code: gplot(eye(length(x)) , [x , y], '*');gplot(eye(length(x)) , [x , y], '*'); )
use ones matrix instead of identity matrix as argument in gplot.
gplot(ones(length(x)), [x , y])
Brian
Brian le 2 Sep 2013
Thanks a lot, works perfect

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Exploration dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by