PLOT ARRAY OF SURF PLOTS IN ONE PLOT
조회 수: 2 (최근 30일)
이전 댓글 표시
I have mutltiple text files with x, y, and z data attached. This files are named in matrix form according to their location.
I would like to create one surf plot that combine the surf plot of the individual text files. The x, and y data can be continuous row and column numbering but the z data remain the same.
Will appreciate a help. Pls let me know if you need more info.
Thanks in advance.
댓글 수: 0
채택된 답변
Walter Roberson
2022년 6월 16일
load() each file. Extract column 3. reshape it as 614 x 588 and then transpose it to 588 x 614. Store in a cell array according to the information from the file name.
When they are all loaded, cell2mat to get the overall Z matrix.
댓글 수: 7
Walter Roberson
2022년 6월 23일
filename11 = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1037665/1,1.txt';
filename12 = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1037670/1,2.txt';
filename21 = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1037675/2,1.txt';
filename22 = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1037680/2,2.txt';
D11 = readmatrix(filename11); c11 = max(D11(:,2));
D12 = readmatrix(filename12); c12 = max(D12(:,2));
D21 = readmatrix(filename21); c21 = max(D21(:,2));
D22 = readmatrix(filename22); c22 = max(D22(:,2));
C{1,1} = uint8(reshape(D11(:,3), c11, [])).';
C{1,2} = uint8(reshape(D12(:,3), c12, [])).';
C{2,1} = uint8(reshape(D21(:,3), c21, [])).';
C{2,2} = uint8(reshape(D22(:,3), c22, [])).';
C
rows = cellfun(@(M) size(M,1), C);
cols = cellfun(@(M) size(M,2), C);
targcols = max(cols, [], 1);
targrows = max(rows, [], 2);
colpadleft = cellfun(@(M) [M, zeros(size(M,1),targcols(1)-size(M,2))], C(:,1), 'uniform', 0);
colpadright = cellfun(@(M) [M, zeros(size(M,1),targcols(2)-size(M,2))], C(:,2), 'uniform', 0);
colpad = [colpadleft, colpadright];
colpad
rowpadup = cellfun(@(M) [M; zeros(targrows(1)-size(M,1),size(M,2))], colpad(1,:), 'uniform', 0);
rowpaddown = cellfun(@(M) [M; zeros(targrows(2)-size(M,1),size(M,2))], colpad(2,:), 'uniform', 0);
rowpad = [rowpadup; rowpaddown];
padded = cell2mat(rowpad);
imshow(padded)
The black lines are the places the subsection was padded on the right or bottom.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!