How do you store the output of a function?
87 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I wrote a function "problem8 (r,x)" and am using it in a new script:
problem8 (0.5,0:5)
When I run the above script, this is what I see in my command window:
x =
0 1 2 3 4 5
y =
0 0 -1 -3 -6 -10
I would like for these vectors or arrays (x and y) to be stored in my workspace but am not sure how to do so.
0 Commenti
Risposta accettata
Star Strider
il 18 Gen 2015
Change the first line of your function to:
function [x, y] = problem8 (r,x)
Then call it as:
[x, y] = problem8(0.5,0:5)
and the values of ‘x’ and ‘y’ should be in your workspace.
You have to ask your function to return the results you’re interested in as output.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Multidimensional Arrays in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!