how to convert char into text??

15 ビュー (過去 30 日間)
Muhammad RSMY
Muhammad RSMY 2017 年 12 月 28 日
回答済み: Muhammad RSMY 2017 年 12 月 28 日
hi guys
I have files with same name but different extension numbers
for example
filename='file_';
fileExt='22'
name=[filename,fileExt];
the output name
name='file_22'
but I need the output just as text, I am planning to call function from this output
% I need the output to like
name=file_22
any possible ways, thanks
  2 件のコメント
Walter Roberson
Walter Roberson 2017 年 12 月 28 日
Do you mean that you need to access a variable named file_22 in that statement?
Muhammad RSMY
Muhammad RSMY 2017 年 12 月 28 日
yes... any possibility

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

採用された回答

Birdman
Birdman 2017 年 12 月 28 日
You can use str2func command for this purpose.
fun=str2func(name)
By this you will create a function handle and then you may call it by typing
fun(..,..)
  3 件のコメント
Birdman
Birdman 2017 年 12 月 28 日
Ok, consider you wrote a function called summing, which sums two numbers.
function y=summing(a,b)
y=a+b;
end
Then, write the following lines:
name='summing';
fun=str2func(name);
y=fun(1,2)
which will result in 3.
Muhammad RSMY
Muhammad RSMY 2017 年 12 月 28 日
Thanks so much, problem is solved

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

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2017 年 12 月 28 日
  1 件のコメント
Muhammad RSMY
Muhammad RSMY 2017 年 12 月 28 日
編集済み: Muhammad RSMY 2017 年 12 月 28 日
difficult for me to understand it, could you explain please,, thanks after all

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


Muhammad RSMY
Muhammad RSMY 2017 年 12 月 28 日
Thanks Birdman and Walter Roberson for your kind support

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by