Coordinates In workspace to x1 y1 ,x2 y2
6 views (last 30 days)
Show older comments
Himanshu Tomar
on 25 Jan 2016
Commented: Walter Roberson
on 27 Jan 2016
I have a variable X= [3,2,4,5] , Y=[5,3,3,6] , similarly many other in my workspace. How do I plot these variables individually. I am using a list box in which all these variables are listed. To plot line X the coordinates would be x1=3, y1=2 ,x2=4 ,y2=5, so how can i convert the 4 element vector(X,Y,..) into a x1,y1,x2,y2 format . thanx in advance
7 Comments
Walter Roberson
on 27 Jan 2016
I need to see the code that sets the String property of your listbox, and I need to see whatever code uses the Value property of your listbox to decide what is being done.
Accepted Answer
Walter Roberson
on 25 Jan 2016
Edited: Walter Roberson
on 25 Jan 2016
x1 = Variable(1);
y1 = Variable(2);
x2 = Variable(3);
y2 = Variable(4);
Or
Variable_cell = num2cell(Variable);
[x1, y1, x2, y2] = Variable_cell{:};
Now if the point was to plot the variables then
plot(Variable([1 3]), Variable([2 4]))
with no need to break it into x1/y1/x2/y2
3 Comments
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!