Reputation: 340
assume I have X,Y
x=[03/01/2017,24/01/2017]% datetime type
y=[1000,2000] % numeric value
How can I draw a rectangle between those "coordinates" I am having trouble since one of them its DateTime value and the other one is numeric. using a plot function? thanks.
Upvotes: 0
Views: 387
Reputation: 36
try:
x = datetime([2017,2017],[1,1],[3,24]); % x = [03/01/2017,24/01/2017]
y = [1000,2000];
fill(x([1,2,2,1]),y([1,1,2,2]),'red')
It doesn't matter that x is datetime and y is numeric
Upvotes: 0
Reputation: 184
The date time can't be treated as coordinates. If you are so sure to plot the rectangle you may need to convert the date time into a serial date number...
x = datenum(x);
Upvotes: 0