フィルターのクリア

How to call a function with a char variable

3 ビュー (過去 30 日間)
Bharat
Bharat 2015 年 7 月 5 日
編集済み: dpb 2015 年 7 月 6 日
Hello, Can someone help me with a small problem?
I stored my workspace as: s= whos() THe actual values are: s(1).name = A,s(2).name = B
[X Y] = coordinates(A,B) works while
[X Y] = coordinates(s(1).name, s(2).name,1); doesn't work?
How do I resolve this?
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2015 年 7 月 5 日
編集済み: Azzi Abdelmalek 2015 年 7 月 5 日
What is coordinates? Can you post an example?

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

採用された回答

dpb
dpb 2015 年 7 月 5 日
Don't do this!!! Use save/load or some other form instead.
If you think you really, really must do this for some reason, then you're treading on thin ice -- read the info under eval to see why and alternatives for various programming paradigms. But, with the above caveat,
[X Y] = coordinates(eval(s(1).name), eval(s(2).name,1));
should, presuming that the variables in s(1:2) are appropriate inputs for the function or are indeed A and B after the execution of whos. But, who's to know that's really the case?
  2 件のコメント
Bharat
Bharat 2015 年 7 月 5 日
I don't understand why I shouldn't but it works! Thanks
dpb
dpb 2015 年 7 月 5 日
編集済み: dpb 2015 年 7 月 6 日
Carry on down this road a while longer and I can assure you that you'll find out why... :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by