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일

0 개 추천

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

Muhammad RSMY
Muhammad RSMY 2017년 12월 28일
편집: Muhammad RSMY 2017년 12월 28일
still quite confusion, could you please explain how to call it,, thanks after all
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일

0 개 추천

댓글 수: 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일

0 개 추천

Thanks Birdman and Walter Roberson for your kind support

카테고리

도움말 센터File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

질문:

2017년 12월 28일

답변:

2017년 12월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by