How to call a function with multiple inputs in a script file?

์กฐํšŒ ์ˆ˜: 115 (์ตœ๊ทผ 30์ผ)
ANIK ACHARJEE
ANIK ACHARJEE 2020๋…„ 7์›” 5์ผ
ํŽธ์ง‘: madhan ravi 2020๋…„ 7์›” 5์ผ
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?

์ฑ„ํƒ๋œ ๋‹ต๋ณ€

KALYAN ACHARJYA
KALYAN ACHARJYA 2020๋…„ 7์›” 5์ผ
ํŽธ์ง‘: KALYAN ACHARJYA 2020๋…„ 7์›” 5์ผ
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
madhan ravi
madhan ravi 2020๋…„ 7์›” 5์ผ
Why do you keep editing the answer?

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์ถ”๊ฐ€ ๋‹ต๋ณ€ (1๊ฐœ)

madhan ravi
madhan ravi 2020๋…„ 7์›” 5์ผ
ํŽธ์ง‘: madhan ravi 2020๋…„ 7์›” 5์ผ
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.

์นดํ…Œ๊ณ ๋ฆฌ

Help Center ๋ฐ File Exchange์—์„œ MATLAB์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

ํƒœ๊ทธ

Community Treasure Hunt

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

Start Hunting!

Translated by