convert time & calculate performance

I need to represent the performance of multple programs by time elapsed vs size.But I don't know how to convert time I got. Also is my way correct to represent my Data ?
I will appricated any help.
X=[ '0m45.364s','0m45.097s','0m46.984s','0m44.962s','1m29.656s']; % this is time elapsed
Y = [200,400,600,800,1000,1200,1400,1600,1800,2000]; % the size
figure
hold on % allow all vectors to be plotted in same
% figure
plot(t, X, 'blue', t, Y, 'red', t, Z, 'green')
title('Row versus column ') % title
ylabel('Matrics size') % label for y axis
xlabel('Millisecond') % label for x axis
legend('Trial 1', 'Trial 2')
legend('Location','NorthWest') % move legend to upper left

6 个评论

You have different number of entries in X and Y?
You will need to use {} for X instead of [] and you will need to convert to a numeric time. duration() with InputFormat option for the conversion.
How to convert time please?
duration(CellArrayOfCharacterVectors, 'InputFormat', 'm''m''s.SSS''s''')
I wrote the conversion format from memory. It might need an adjustment.
Not work with me :(.
Would you please fix whole operations?
I do not have access to matlab at the moment.
Did you change to {} in X? The [] you have would create one long character vector instead of a collection of items.
Yes fixed but the problem still there. I'm new user for matlab if anyone can fix all my code I will appricated.

请先登录,再进行评论。

 采纳的回答

X={ '0m45.364s','0m45.097s','0m46.984s','0m44.962s','1m29.656s'};
dt = datetime(X, 'InputFormat', 'm''m''s.SSS''s''');
Xms = milliseconds(dt - dateshift(dt, 'start', 'day'));
I used milliseconds rather than seconds because your x label says milliseconds. On the other hand, your x label is for your t variable (that we do not have values for), and your y label is for matrix size, which is in the 200 to 2000 range. It is not clear to me why you would plot elapsed time on the same axes as matrix size. It would make more sense to me if your were using the milliseconds from X as your X axis.

15 个评论

you can ignore my labels I want to calculate as my results.
Any suggetstions how to represent my data? I'm still begginer.
I got this after some suggetsions but still not working.
X={ '0m45.364s','0m45.097s','0m46.984s','0m44.962s','1m29.656s'};
Y = [200,400,600,800,1000,1200,1400,1600,1800,2000]; % the size
dt = datetime(X, 'InputFormat', 'm''m''s.SSS''s''');
Xms = milliseconds(dt - dateshift(dt, 'start', 'day'));
figure
hold on % allow all vectors to be plotted in same
% figure
plot( Xms, 'blue', Y, 'red')
title('Row versus column ') % title
ylabel('Matrics size') % label for y axis
xlabel('Millisecond') % label for x axis
legend('Trial 1', 'Trial 2')
legend('Location','NorthWest') % move legend to upper left
It looks like Walter got you past the first hurdle. timeofday would also have worked (instead of subtracting off a dateshift'ed value and calling milliseconds). Your main problem now seems to be that you have 5 elapsed times, and 10 sizes. It's not clear what you want to plot against what, but I imagine you want to have 5 more times, to split the sizes into two vectors, and do somethng like
plot(x1,y1,'b',x2,y2,'r')
and no "hold on" needed.
I tried what you said but not working.
X={ '0m45.364s','0m45.097s','0m46.984s','0m44.962s','1m29.656s'};
Y = [200,400,600,800,1000]; % the size
dt = datetime(X, 'InputFormat', 'm''m''s.SSS''s''');
Xms = milliseconds(dt - dateshift(dt, 'start', 'day'));
figure
% hold on % allow all vectors to be plotted in same
% figure
plot(x1,y1,'b',x2,y2,'r')
title('Row versus column ') % title
ylabel('Matrics size') % label for y axis
xlabel('Millisecond') % label for x axis
legend('Trial 1', 'Trial 2')
We do not have xy, y1, x2, y2, and you are not using Xms or Y.
Note: using timeofday() would not have worked with the original code because you are plotting the elapsed time on the Y axis with plot(t,X) and you were plotting other numeric things on the Y axis as well, so it was necessary to convert the elapsed time to numeric form so as to avoid a confict over whether the Y axis was to be duration objects or was to be numeric.
With the revised code... we do not know how the elapsed time is being used. Possibly we could have used durations.
would you fix the code please . I feel lost/:
I cannot fix the code because I do not know how x1, y1, x2, y2 relate to X or Y.
x1, y1, x2, y2
I got those from previous comments.So ignore them
I need to implement performance of my code for Matrics.
This is the different times.
'0m45.364s','0m45.097s','0m46.984s','0m44.962s','1m29.656s'
versus size of Matrics.
Any suggestions?
would you plaease help me to plot mutiple line please.
plot(sort(rand(1,10)), rand(1,10), 'r');
hold on
plot( sort(rand(1,20)), rand(1,20), 'g'); %second line being plotted
plot( sort(rand(1,15)), rand(15,3), 'k'); %three more lines, one for each COLUMN of y
hold off
Your first question is too confusing to me, sorry.
So I have separete dataset and I need to import them and plot all of them in same plot.

请先登录,再进行评论。

更多回答(0 个)

类别

标签

Community Treasure Hunt

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

Start Hunting!

Translated by