0
$\begingroup$

I have a law under which the current changes, and i need to find values of current evry f sec. Code is:

Alpha = 0.0051;
Irf[t_, T_] := If[t <= T, Alpha*t, 2*T*Alpha - Alpha*t]*Milli Ampere
Period := 50/2;
Plot[Irf[t, Period]/(Milli Ampere), {t, 0, 2 Period}, 
 AxesLabel -> {t, Subscript[I, rf]}]

t1 = 0;
t2 = 25;
f = 5;(*time goes from t1 to t2 in steps of 1*) 

k = For[i = 0; t = x, i*f <= Period, i++, t = Alpha*(i*f); Print[t]]

As a result I have current values ​​corresponding to a certain time which are written into the column, as it is possible to write them in a row and create a list.

That's what i have:

0.

0.0255

0.051

0.0765

0.102

0.1275

And I want it to look like this: {0., 0.0255, 0.051, 0.0765, 0.102, 0.1275}

$\endgroup$
2
  • 4
    $\begingroup$ Use Table not For. $\endgroup$
    – Kuba
    Commented Mar 20, 2017 at 22:27
  • 1
    $\begingroup$ Irf[#, Period]/(Milli Ampere) & /@ Range[t1, t2, f] $\endgroup$
    – bienti
    Commented Mar 21, 2017 at 9:40

1 Answer 1

1
$\begingroup$
Alpha = 0.0051;
list={};
Irf[t_, T_] := If[t <= T, Alpha*t, 2*T*Alpha - Alpha*t]*Milli Ampere
Period := 50/2;
Plot[Irf[t, Period]/(Milli Ampere), {t, 0, 2 Period}, 
AxesLabel -> {t, Subscript[I, rf]}]

t1 = 0;
t2 = 25;
f = 5;(*time goes from t1 to t2 in steps of 1*) 

k = For[i = 0; t = x, i*f <= Period, i++, t = Alpha*(i*f);AppendTo[list,t]];
list
$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.