could anyone help me how the numbers can be separated if they are joined together
1 次查看(过去 30 天)
显示 更早的评论
for example 54 is the number i want to separate it into 5 and 4. could anyone please help me on this.
0 个评论
采纳的回答
更多回答(1 个)
Stephen23
2018-3-26
General solution:
>> num2str(54)-'0'
ans =
5 4
5 个评论
per isakson
2018-3-26
I try to rephrase my question.
Isn't this easier to understand for when coming new to Matlab and computer programming?
Stephen23
2018-3-26
编辑:Stephen23
2018-3-26
"Isn't this easier to understand for when coming new to Matlab..."
Based on questions on this forum (for example some beginners think that '1' has value 1) I don't see any significant benefit in hiding the fact that '1' has value 49 under some unnecessary obfuscation that the character must be first converted to double before it is operated on. I believe the sooner that one learns that ASCII/char values can be manipulated directly the easier it is to work with char arrays, and that most beginners are able to grasp a simple concept like "char arrays can be operated on directly".
"...and computer programming?"
And again judging by questions on this forum, often computer programmers seem to have the hardest time understanding MATLAB, because they come with preconceived ideas of how things should be done. The faster they leave those preconceptions behind and actually learn how MATLAB works, the faster they will learn how to use MATLAB effectively. I don't see how hiding basic MATLAB concepts will help them.
Arrays are the basic MATLAB type, and the ease of array creating, manipulation, and calculations has so far been unsurpassed by any other language (and that includes Julia, which tried very hard). I believe that learning basic numeric/char/cell/struct/... array manipulation concepts will be a benefit to anyone who learns MATLAB, and should in fact be learned as fast as possible, rather than delayed.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!