cell2mat Error :using cat Dimensions of arrays being concatenated are not consistent.

조회 수: 19 (최근 30일)
Hello,
I have a cell array which is as follows:
I am using
P2 = cell2mat(Numerical_FourierForce{1,1})
and I get this error:
Error using cat
Dimensions of arrays being concatenated are not consistent.
Is there any way to avoid this error?
Because in the picture, I have some cells with 0 and some with two values, these values are forces in x and y and zero is for both of them.
Is ther any way, I could convert them into ordinary array?

채택된 답변

Stephen23
Stephen23 2020년 7월 16일
%P2 = {0,[1;2];0,0}; % test data
P2 = Numerical_FourierForce{1,1};
X = cellfun(@(a)isequal(a,0),P2);
P2(X) = {[0;0]};
P2 = cell2mat(P2)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by