defined string as input for function

I have function which use load file that have some string inside it which I used it as input to my function so, I defined the load file and the input as the following:
load(file1) //file1 name is defined up so, I can change it any time
and I defined the input like
x11= low;
y11= vlow;
then in the function I defined the input as
x=x11;
y=y11;
but when I run it t give me undefined variables low & vlow. In addition, if I write x=low & y=vlow with out define it up it work .

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 4 月 6 日

0 投票

load() does not execute MATLAB commands present in text files. If you want to execute MATLAB commands in a file then you should run() the file.

4 件のコメント

Ahmed Alshehhi
Ahmed Alshehhi 2018 年 4 月 6 日
by the way this function I use it in GUI, it still not clear to my how I can solve this problem
Walter Roberson
Walter Roberson 2018 年 4 月 6 日
When x11 is mentioned, then is it expected to have the same content as a previously-defined variable named low, or is it expected to contain the string 'low' ? If it is expected to have a copy of the previously-defined variable named low then which workspace has that variable been defined in?
Ahmed Alshehhi
Ahmed Alshehhi 2018 年 4 月 6 日
it is defined in the load file
Walter Roberson
Walter Roberson 2018 年 4 月 12 日
Is the file being loaded a .mat file, is is a text file containing the lines
x11= low;
y11= vlow;
and before that in the text file there is an assignment to the variables 'low' and 'vlow' ??

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

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

タグ

質問済み:

2018 年 4 月 6 日

コメント済み:

2018 年 4 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by