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

10 次查看(过去 30 天)
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!

采纳的回答

dpb
dpb 2020-11-8
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 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by