フィルターのクリア

How to I referrence a value (matrix) from script file to a function file

5 ビュー (過去 30 日間)
Jay
Jay 2015 年 7 月 30 日
回答済み: Adam 2015 年 7 月 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 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2015 年 7 月 30 日
What is your problem? what [reference val from script] means?

サインインしてコメントする。

採用された回答

Adam
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.

その他の回答 (1 件)

Milad Abdollahi
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;
  1 件のコメント
Jay
Jay 2015 年 7 月 30 日
Thanks but the function file will not accept it.
I have a matrix with the values I need it to read but will not read the matrix in the script file.
I am trying to get it to print the error ellipses specified in a script file with the same format as the function "h"
1.84223375971567e-05 8.60830550425011e-06 0.708169816720015 5610.76102569771 1504.71436962626 98 500
4.88908766745609e-05 2.39606721328394e-05 0.617893601519282 5521.73718511727 595.543987930735 98 500
4.77538681625383e-05 3.26740639762490e-05 0.260131216166967 5111.56235703524 623.715944597357 98 500

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeElectrical Block Libraries についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by