Convert a cell to an array with a data type other than double

I have a cell array full of data (We'll call A) that I need to get into an array. When I try str2num(cell2mat(A)) the resulting values are in double but this cuts offs many decimal places that I need. How can I convert a cell to an array with a data type other than double?

2 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 7 月 23 日
can you post a short example with expected result?
James Tursa
James Tursa 2015 年 7 月 23 日
Are you sure it "cuts off" the decimal places, or is this just a display issue. Try the following:
format long g

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

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 7 月 23 日

0 投票

I guess your data looks like
A={1 '2' 3;4 '5.55' 3.66;6 '14' 4.78}
B=str2double(cellfun(@num2str,A,'un',0))

カテゴリ

ヘルプ センター および File ExchangeData Type Conversion についてさらに検索

質問済み:

2015 年 7 月 23 日

コメント済み:

2015 年 7 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by