Dear Community,
I have a 294x1 cell array, where each variable is a number and from this cell I need to create 2 cell arrays each of 49x1, where each variable of this new cell arrays contains 3 variables of the first array. How would you do that?
This is what I got so far:
Last_vektor = num2cell(Ubertragungsmatrix(:,end));
Load_vector = reshape(Last_vektor,[98,1]);
Pu_tr = cell(49,1);
Pn_tr = cell(49,1);

 채택된 답변

madhan ravi
madhan ravi 2020년 10월 3일
편집: madhan ravi 2020년 10월 3일

0 개 추천

Vielleicht?
C = num2cell(reshape(Ubertragungsmatrix(:, end), 294/2, []), 1);
C1 = num2cell(cellfun(@(x) {reshape(x, [], 3)}, C));
[Pu_tr, Pn_tr] = deal(C1{ : })

댓글 수: 2

Marcelo Boldt
Marcelo Boldt 2020년 10월 3일
It is an interesting approach indeed, but now I am getting 1x1 cell (49x3 double), no Idea how to modify that
Pu_tr{ : }

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

madhan ravi
madhan ravi 2020년 10월 3일

0 개 추천

Bessere Version:
V = reshape(Ubertragungsmatrix(:, end), [], 3, 2);
V1 = squeeze(num2cell(V, [1, 2]));
[Pu_tr, Pn_tr] = deal(V1)

댓글 수: 3

Marcelo Boldt
Marcelo Boldt 2020년 10월 3일
this approach leaves me with each variable with a 2x1 cell each variable containing 147x1 vector
madhan ravi
madhan ravi 2020년 10월 3일
편집: madhan ravi 2020년 10월 3일
It’s assumed that Ubertragungsmatrix(:, end) is a vector with 294 elements. size(Pu_tr) size(Pn_tr) % paste the output here
Marcelo Boldt
Marcelo Boldt 2020년 10월 3일
yes that's right, its a 294x1 vector. that I want to convert to two 49x1 cell, each variable contianing a 3x1 vector

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

2020년 10월 3일

댓글:

2020년 10월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by