How do I combine vectors to form a matrix?

조회 수: 4 (최근 30일)
Franchesca
Franchesca 2014년 5월 14일
답변: Andrei Bobrov 2014년 5월 14일
I am trying to run a loop which puts column 5 from every cell in this array shown below into a new matrix:
This is my code at the moment:
combined = [6050,54]
for i=1:length(mydata)
combined(:,i) = mydata{i,1}(:,5);
end
This is the error I recieve:
Subscripted assignment dimension mismatch.
Error in MatlabCoursework (line 84) combined(:,i) = mydata{i,1}(:,5);

채택된 답변

Andrei Bobrov
Andrei Bobrov 2014년 5월 14일
combined = cell2mat(cellfun(@(x)x(:,5),mydata,'un',0));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by