# How can I plot the graph based on time from TimeUsed?

Good day everyone,

Can anyone help me how to plot the result using time from computer. Here, I used timeUSed to generate the time;

α = 2*Pi;
For[t = 0, t < 10, t++, eg = {{1/4, 1/4, (1/2)*((1/2)*Cos[(α*t)/2] - (1/2)*Sin[(α*t)/2]), (1/2)*((1/2)*Cos[(α*t)/2] + (1/2)*Sin[(α*t)/2])},
{1/4, 1/4, (1/2)*((1/2)*Cos[(α*t)/2] - (1/2)*Sin[(α*t)/2]), (1/2)*((1/2)*Cos[(α*t)/2] + (1/2)*Sin[(α*t)/2])},
{(1/2)*((1/2)*Cos[(α*t)/2] - (1/2)*Sin[(α*t)/2]), (1/2)*((1/2)*Cos[(α*t)/2] - (1/2)*Sin[(α*t)/2]),
((1/2)*Cos[(α*t)/2] - (1/2)*Sin[(α*t)/2])^2, ((1/2)*Cos[(α*t)/2] - (1/2)*Sin[(α*t)/2])*((1/2)*Cos[(α*t)/2] + (1/2)*Sin[(α*t)/2])},
{(1/2)*((1/2)*Cos[(α*t)/2] + (1/2)*Sin[(α*t)/2]), (1/2)*((1/2)*Cos[(α*t)/2] + (1/2)*Sin[(α*t)/2]),
((1/2)*Cos[(α*t)/2] - (1/2)*Sin[(α*t)/2])*((1/2)*Cos[(α*t)/2] + (1/2)*Sin[(α*t)/2]), ((1/2)*Cos[(α*t)/2] + (1/2)*Sin[(α*t)/2])^2}};
m1 = Det[eg]; t = t + TimeUsed[];


I want to Plot m1 versus t (increment by TimeUsed[]).

How can I do the coding for plotting?

Thank you very much

I will do it in a little different way.

α = 2*Pi;
eg[t_] = {{1/4, 1/4, (1/2)*((1/2)*Cos[(α*t)/2] - (1/2)*Sin[(α*t)/2]), (1/2)*((1/2)*Cos[(α*t)/2] + (1/2)*Sin[(α*t)/2])},
{1/4, 1/4, (1/2)*((1/2)*Cos[(α*t)/2] - (1/2)*Sin[(α*t)/2]), (1/2)*((1/2)*Cos[(α*t)/2] + (1/2)*Sin[(α*t)/2])},
{(1/2)*((1/2)*Cos[(α*t)/2] - (1/2)*Sin[(α*t)/2]), (1/2)*((1/2)*Cos[(α*t)/2] - (1/2)*Sin[(α*t)/2]),
((1/2)*Cos[(α*t)/2] - (1/2)*Sin[(α*t)/2])^2, ((1/2)*Cos[(α*t)/2] - (1/2)*Sin[(α*t)/2])*((1/2)*Cos[(α*t)/2] + (1/2)*Sin[(α*t)/2])},
{(1/2)*((1/2)*Cos[(α*t)/2] + (1/2)*Sin[(α*t)/2]), (1/2)*((1/2)*Cos[(α*t)/2] + (1/2)*Sin[(α*t)/2]),
((1/2)*Cos[(α*t)/2] - (1/2)*Sin[(α*t)/2])*((1/2)*Cos[(α*t)/2] + (1/2)*Sin[(α*t)/2]), ((1/2)*Cos[(α*t)/2] + (1/2)*Sin[(α*t)/2])^2}};

data=Table[Join[{t}, Timing[Det[eg[t]]]], {t, 0, 10}]


{{0, 0.000423, 0}, {1, 0.000459, 0}, {2, 0.000505, 0}, {3, 0.000544, 0}, {4, 0.000489, 0}, {5, 0.000518, 0}, {6, 0.00047, 0}, {7, 0.000387, 0}, {8, 0.000397, 0}, {9, 0.000467, 0}, {10, 0.00046, 0}}

Now you have a list of {t, time used, det}. You can choose any two of them and plot them with ListPlot or ListLinePlot like

ListPlot[data[[All,{1,2}]]]


Using For

data = {};(*Empty List*)
For[t = 0, t < 10, t++,
data = Join[{Join[{t}, Timing[Det[eg[t]]]]}, data]]

• thank you for helping me but I have a question here: 1. What it mean by Join? 2. In ListPlot, {1,2} represent what value? thank you . – munirah Jul 27 '16 at 15:08
• if there any way to plot by using For loop? Actually, I dont really understand – munirah Jul 27 '16 at 15:21
• 1. data is a 3xn array. data[[All,{1,2}]] takes all elements at the second and third column. You need to use a two column array for ListPlot. 2. Join[{a},{b,c}]={a, b, c}. – Sumit Jul 28 '16 at 7:32
• thank you. I will test it. – munirah Jul 29 '16 at 5:29
• Timing is a mathematica command. If you want to know more about any command, go to Help>Wolfram Documentation and type it. It will show you all details and examples. – Sumit Jul 29 '16 at 11:05