PLOT ARRAY OF SURF PLOTS IN ONE PLOT
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
OLUWAFEMI AKINMOLAYAN
le 16 Juin 2022
Commenté : Walter Roberson
le 23 Juin 2022
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 commentaires
Réponse acceptée
Walter Roberson
le 16 Juin 2022
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 commentaires
Walter Roberson
le 23 Juin 2022
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Type Conversion dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!