フィルターのクリア

indexing problem in cell array

2 ビュー (過去 30 日間)
ayman mounir
ayman mounir 2019 年 8 月 2 日
コメント済み: Adam Danz 2019 年 8 月 21 日
As the attached image when i am indexing the second row which for examble 54 and convert it to string or chararcter it would not work. and i used calss to identify it, it showed as a cell.
anyway i just i need to use as a string as the following: ' 54 Ah '
Thanks in advance

採用された回答

Adam Danz
Adam Danz 2019 年 8 月 20 日
Tested on r2014a (after brushing the dust off of it).
% Create cell array as is described in the quesiton
Zellprojekte = struct;
Zellprojekte.Z15 = {'B1', 'A2'; 54, 37; 'CATL', 'CATL'};
% Convert numbers to strings (chars)
cellfun(@num2str,Zellprojekte.Z15,'UniformOutput',false)
Result
ans =
3×2 cell array
{'B1' } {'A2' }
{'54' } {'37' }
{'CATL'} {'CATL'}
  1 件のコメント
Adam Danz
Adam Danz 2019 年 8 月 21 日
" i just i need to use as a string as the following: ' 54 Ah '"
sprintf('%d %s', 54, 'Ah')
ans =
'54 Ah'
%d for the integer
%s for the string.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by