我也許會討論這個錯誤,但我有數據{1},數據{2} ...數據{i}。在每個中,我有.type1,.type2 .... .typeN。數組長度不同,所以水平連接不起作用。連接不同大小的1D矩陣
爲了簡單起見
>> data{1}.type1
ans =
1
2
3
>> data{2}.type1
ans =
2
4
5
6
結果應該是[1; 2; 3; 2; 4; 5; 6]
我一直在試圖循環,但不知道如何?我將有可變數量的文件(a,b ..)。我如何去循環和連接?最後,我需要這一切的1×N個陣列..
我的工作代碼,thanks..figured出來..
for i = 1:Types
currentType = nTypes{i}
allData.(currentType)=[];
for j = 1:nData
allData.(currentType) = [allData.(currentType); data{j}.(currentType)(:,3)]; %3rd column
end
end
'[a; b]'。或者'vertcat(a,b)'。或'c = {a,b}; vertcat(c {:})' –
這不是「離題」來解釋你的輸入數據。根據您的意見,看起來您的示例代碼太簡單了,無法解釋您的實際問題。嘗試一些示例代碼,使其更接近您需要的內容。 – Peter