Effacer les filtres
Effacer les filtres

Is there a way to change the value of a variable within a function?

2 vues (au cours des 30 derniers jours)
Et.B200
Et.B200 le 8 Nov 2020
Commenté : Rik le 10 Nov 2020
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!

Réponse acceptée

dpb
dpb le 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.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by