![]() |
Matlab合并矩阵
student1 student2 student3 code score code score code score 1 20 1 100 1 22 2 11 3 11 2 90 3 12 4 22 5 11 4 11 5 28 这个问题与[URL="https://stackoverflow.com/questions/3174631/matlab-how-to-combine-uneven-matric-into-single-matrix"]如何将不均匀矩阵组合成一个矩阵有关?[/URL]但是有点不同。我想合并具有不同大小的n个文件。每个文件读取循环。我如何获得如下所示的输出?
for i=1:n .... inputdata=[code score]; sortdata= sortrows(inputdata,1); end Output code s1 s2 s3 1 20 100 22 2 11 0 90 3 12 11 0 4 11 22 0 5 28 0 11 [B]回答:[/B] 代替 inputdata=[code score]; sortdata = sortrows(inputdata,1); 使用 completedata(code, n+1) = score; 这样,您将code用作最终数组的索引。在循环之前初始化completedata可能是一个好主意。 completedata = [(1:codemax)', zeros(codemax, n)]; [url=https://stackoverflow.com/questions/3175518]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 01:09。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.