How do you output the values of temporary variables from a function when it runs?
Ältere Kommentare anzeigen
I am trying to better understand this function:
It gives an example of how to run the function as:
sos = adf(130.81,0.00015,4300,0.85);
If I input the full function and run this example line, it seems to work fine. If I then just type "sos" on a new line it outputs the values of "sos" as expected.
But how can I see the values of arrays/vectors/variables that were used in the process of creating this "sos" array? Eg. If you look at the code, one of the things it runs along the way is:
phik = pi*[1:2:2*nap-1];
How can I see the values of "phik"? If I just type "phik" after running the script as above it tells me the variable is undefined. But "phik" had to be defined in the process of creating "sos" since it's part of the function. Is there any way to get it to remember or store "phik" when it runs through the script or output it once it's done so I can see what it put in there along the way? How do I see "phik"?
Thanks.
1 Kommentar
Stephen23
am 9 Mai 2020
"How do you output the values of temporary variables from a function when it runs?"
That is exactly what debugging tools are for.
All programming languages have debugging tools because programmers want to look at what their code does when it is run. And so they develop tools to do exactly that:
Akzeptierte Antwort
Weitere Antworten (1)
Steven Lord
am 9 Mai 2020
0 Stimmen
You could modify the function so it also returns the "temporary" variables or you could debug your code.
Kategorien
Mehr zu Variables finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!