Effacer les filtres
Effacer les filtres

how to convert char into text??

30 vues (au cours des 30 derniers jours)
Muhammad RSMY
Muhammad RSMY le 28 Déc 2017
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 commentaires
Walter Roberson
Walter Roberson le 28 Déc 2017
Do you mean that you need to access a variable named file_22 in that statement?
Muhammad RSMY
Muhammad RSMY le 28 Déc 2017
yes... any possibility

Connectez-vous pour commenter.

Réponse acceptée

Birdman
Birdman le 28 Déc 2017
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 commentaires
Birdman
Birdman le 28 Déc 2017
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 le 28 Déc 2017
Thanks so much, problem is solved

Connectez-vous pour commenter.

Plus de réponses (2)

Walter Roberson
Walter Roberson le 28 Déc 2017
  1 commentaire
Muhammad RSMY
Muhammad RSMY le 28 Déc 2017
Modifié(e) : Muhammad RSMY le 28 Déc 2017
difficult for me to understand it, could you explain please,, thanks after all

Connectez-vous pour commenter.


Muhammad RSMY
Muhammad RSMY le 28 Déc 2017
Thanks Birdman and Walter Roberson for your kind support

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by