How to I referrence a value (matrix) from script file to a function file
3 ビュー (過去 30 日間)
古いコメントを表示
I have a function file that has a subroutine.
When I run the subroutine I want to then reference a value from the script file when running the function file.
eg.
val = 5 (in script file)
that script file runs the function file
said function file then references val from the script file.
1 件のコメント
採用された回答
Adam
2015 年 7 月 30 日
The point of functions is to have their own scope and workspace so you pass in the things you need as input arguments.
If you script runs your function then it can just pass the relevant value down to the function as an argument.
0 件のコメント
その他の回答 (1 件)
Milad Abdollahi
2015 年 7 月 30 日
You can define your variable in script file by global and the recall it in you function again by global here is an example:
%define global variable in script file
global val
val=5;
use val in function like this
%recall global variable
global val
y=3*val^2+1;
参考
カテゴリ
Help Center および File Exchange で Low-Level File I/O についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!