Is there a way to change the value of a variable within a function?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi everyone,
I was wondering for a function with 4 arguments within it, can I change the value of 2 arguments multiple times and keep two arguments constant, and get an output for the function each time under the same set of data for output?
eg
function v=fctionname (a1,a2,a3,a4)
a1 = 2
a2 = 4
a3 = variable value (changed say 7 times)
a4 variable value (changed say 7 times)
producing
v = 7 different values
Many thanks!
Risposta accettata
dpb
il 8 Nov 2020
You can do anything you want inside the function as long as you can write a definition of what it is that is to happen.
You could pas the a3, a4 variables as arrays and use them as most transparent way but most required of user. If the initial value of a3, a4 are needed and modified, then that's easy enough, too. Or, if they are totally defined by the function, they wouldn't even need to be arguments.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Startup and Shutdown 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!