print cell elements with fprintf

17 ビュー (過去 30 日間)
Ekrem Yavuz
Ekrem Yavuz 2019 年 5 月 2 日
コメント済み: Ekrem Yavuz 2019 年 5 月 2 日
Hello,
I am trying to print cell elements with fprintf command. I have problems about it. The error is "Function is not defined for 'cell' inputs." When i tried to convert cell to mat with cell2mat function, this time another error occurs "All contents of the input cell array must be of the same data type." I think i need to equal all element sizes of cell but i didnt succeed it. I attached this cell as time.mat.
Thank you for your help.
  2 件のコメント
Adam
Adam 2019 年 5 月 2 日
編集済み: Adam 2019 年 5 月 2 日
What are you trying to fprintf? Can't you just access what is inside the cell with { } in your fprintf statement instead of accessing the cell itself?
Stephen23
Stephen23 2019 年 5 月 2 日
Ekrem Yavuz's "Answer" moved here:
Hello Adam,
It is a part of a project. I am writing some sensor datas to a .mtb file. I want to add time stamp to them. I am getting utctime values from sensor and i want to write them to .mtb file. So, that is why i am trying to use fprintf.

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

採用された回答

per isakson
per isakson 2019 年 5 月 2 日
The values of cell one, time{1}, and the rest, time{2:end}, are of different types
>> time{1:2}
ans =
uint32
20579000
ans =
int32
1970
That is the the reason for the error of cellmat()
Try
>> fprintf( '%d ', time{:} ); fprintf('\n')
20579000 1970 1 1 0 0 0 0 0
>> fprintf( '%d ', cell2mat(time(2:end)) ); fprintf('\n')
1970 1 1 0 0 0 0 0
  1 件のコメント
Ekrem Yavuz
Ekrem Yavuz 2019 年 5 月 2 日
Hello per isakson. Many thanks to your reply. It works.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by