How do I print a mixed expression ( numeric and symbolic) to a file?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Example: 3.21 - x
2 commentaires
Star Strider
le 28 Mar 2014
How do you generate your expressions? Symbolic Math Toolbox? Something else?
Réponses (3)
Salaheddin Hosseinzadeh
le 27 Mar 2014
You can use sprintf or easier way is to concatnate strins
myString=sprintf();
fprintf(myFile,myString);
or
fprintf(myFile,[num2str(myNumber),' - x']);
and then write the 'mySring' to a file.
I personally never used sprintf , so for furter details abou sprintf refer to MALAB help
doc sprintf
Good Luck!
Salaheddin Hosseinzadeh
le 28 Mar 2014
The only way that I know of is to concatnate just as I showed u! I edited a whole bunch of text files like this.
I don't think if there would be another way around. Just to make it more automatic you may put your strins in a cell array, and also the digits, and use a for loop to do it easier!
names={'Alex','Sam','Max','Sala','Tom','Tim'};
examResult=(20 10 4 13 5 0);
for i= 1:lenght(examResult)
fprintf(myFile,[names(i),'''s exam result=',num2str(i)]);
end
output
Alex's exam result= 20
Sory if it is difficult, sometime I'm looking for super easy ways that does not exits. I don't think if an specific way would exis for you.
Star Strider
le 28 Mar 2014
The only MATLAB functions I can find that deal with unicode characters are unicode2native (and native2unicode that may not apply to what you are doing but has a link at the end of the unicode2native page).
Consider this for a start, and experiment:
bytes = unicode2native('Ξ ξ')
0 commentaires
Voir également
Catégories
En savoir plus sur Labels and Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!