Mathematica Asked on March 27, 2021
I have a generic function:
f[a_,b_]:=Module[{e,f,g,h}]
which returns the scalar g
and the list h
in the form:
{g,h}
.
Because of RandomInteger
inside the Module
block, I have several results for the same function f[a_,b_]
.
My final aim is to have a ListLinePlot
of the different (let’s assume 10) h
output lists on the same graphic.
Instead of launching:
f1=f[a,b];
f2=f[a,b];
f3=f[a,b];
...
f10=f[a,b];
and after that using:
ListLinePlot[{f1[a,b][[2]],f2[a,b][[2]], ... f10[a,b][[2]]}]
I was looking for something like:
ListLinePlot[Table[f[a,b][i][[2]],{i,1,10}]
even though there isn’t any i
dependence.
Any help?
How about
ClearAll@f
f[a_, b_] := {a, RandomInteger[{1, 100}, 10]}
ListLinePlot[Table[f[a, b][[2]], 10]]
Correct answer by Rohit Namjoshi on March 27, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP