MATLAB Answers

Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

Shane
0

Convert char to string

Shane
さんによって質問されました 2012 年 12 月 20 日
I just want to convert a char to str.
The char is in a cell. This is what happens:
>> example = ['hithere',socks]
example =
'hithere' [1x34 char]
>> taken = ['hithere',{socks}]
taken =
'hithere' {1x1 cell}
>> socks
socks =
'Shane'
What am I doing wrong and how can I convert the char into a string.
Cheers, Shane

  0 件のコメント

サインイン to comment.

2 件の回答

Walter Roberson
回答者: Walter Roberson
2012 年 12 月 20 日

I'm not sure but I think perhaps what you want is
[{'hithere'} socks]
But possibly what you want is
['hithere ' socks{1}]

  0 件のコメント

サインイン to comment.


Image Analyst
回答者: Image Analyst
2012 年 12 月 20 日

I don't know how socks was 34 characters in the first example and only 5 characters ('Shane') in the next example. Are any of these what you want:
socks = {'Shane'}
example = ['hithere',socks]
example1 = char(example)
example2 = sprintf('%s %s', example{1}, example{2})

  1 件のコメント

Jan
2012 年 12 月 20 日
I'm still confused about ['string', {'Cell string'}], because it looks like this joins elements of incompatible types. I never had tried it without explicitly converting the string by cellstr() at first.

サインイン to comment.



Translated by