Basic 2D-contour plot
31 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I am very new to Matlab and want to use it for a very basic data visualisation. I found some examples about 2D-contour plots, but no example worked for me and sometimes I had difficulties understanding certain functions.
I have a data file, which contains coordinates in x- and y-direction (first row and first column of an excel sheet). For every given position of these x- and y-coordinates there is a value.
There are plots that look very similar to what I aim for in the end:

My problem is, that getting the data out of my excel-file seems complicated and I don't know how to assign the coordinates to the values in Matlab.
I have currently a visualisation, but this one is based on Excel and does not fit certain optical requirements:

Also the interpolation of data between measured values is not very well done.
I am very glad about every answer that helps!
Best regards
Moritz
0 个评论
回答(1 个)
Star Strider
2022-8-1
编辑:Star Strider
2022-8-1
One optiono is to use the first column and first row as the appropriate coordinate vectors, and then the rest of the matrix as the array to use with contourf.
I am not certain what result you want.
One possibility —
Data = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1084750/data.xlsx')
xv = Data(1,2:end);
yv = Data(2:end,1).';
Cm = Data(2:end, 2:end);
figure
contourf(xv, yv, Cm)
colormap(jet)
colorbar
xlabel('X')
ylabel('Y')
EDIT — (1 Aug 2022 at 14:23)
.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Orange 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
