Convert column into cells

17 ビュー (過去 30 日間)
Marcus Glover
Marcus Glover 2016 年 7 月 11 日
編集済み: Walter Roberson 2016 年 7 月 12 日
I have a large cell matrix with each cell as 1x1 as some entries are strings and other types of imported data. I need to multiply two columns together, as well as a scalar.
The multiplication of coulumns part I have done like this:
final(:,5)=cellfun(@times,final(:,3),final(:,4),'Uni',0);
But I can't seem to multiply by my scalar without running into problems. I can get the correct column of numbers I need like this:
numbers=cell2mat(final(:,5))./1000;
But now I can't convert this back into cells in order to put back into final(:,5). Conversion to cell from double is not possible. mat2cell seem to give me just one cell, but I need a column of individual cells (7108x1).
I have to have final(:,5) be these numbers, I don't care what type it is really as it will be exported as .xls.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 7 月 11 日
final(:,5)=cellfun(@times,final(:,3),final(:,4),'Uni',0);
final(:,5)=cellfun(@(x) x/100,final(:,5),'un',0)

その他の回答 (1 件)

Star Strider
Star Strider 2016 年 7 月 12 日
If you need a column of individual cells from mat2cell. you have to give it a vector of ones.
For example:
v = ...; % Numeric Vector
cv = mat2cell(v, ones(7108,1), 1); % Cell Array

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by