how to convert char into text??
31 次查看(过去 30 天)
显示 更早的评论
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
2017-12-28
Do you mean that you need to access a variable named file_22 in that statement?
采纳的回答
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
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.
更多回答(2 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!