How to call a function with multiple inputs in a script file?
123 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
ANIK ACHARJEE
am 5 Jul. 2020
Bearbeitet: madhan ravi
am 5 Jul. 2020
I have created a function, which has three inputs and three outputs. I want that function to call in a script (.m) file. How can I do that?
0 Kommentare
Akzeptierte Antwort
KALYAN ACHARJYA
am 5 Jul. 2020
Bearbeitet: KALYAN ACHARJYA
am 5 Jul. 2020
Lets say the function name is fun1, which having 3 inputs and 3 outputs . Now call the function form another Matlab script, as follows (plese define all input argumnets before use it.)
[out1,out2,out3]=fun1(in1,in2,in3)
Here out1,out2,out3,in1,in2,in3 are the output and input variable names, you can chooses any name. I expect you had already save the fun1 in another Matlab file named as fun1.m. For details please refer the following link-
Regards
Kalyan Acharjya 😊
1 Kommentar
Weitere Antworten (1)
madhan ravi
am 5 Jul. 2020
Bearbeitet: madhan ravi
am 5 Jul. 2020
https://www.mathworks.com/help/matlab/ref/function.html - on how to use functions properly.
A = 1;
B = 2;
C = 3;
[O1, O2, O3] = yourfunction(A, B, C) % assuming you saved the function in a file called yourfunction.m , from 2016b you can use function definitions directly in script files.
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!