Plotting surface charts when z is not a function of x or y
31 views (last 30 days)
Show older comments
Jabir
on 5 Apr 2024 at 16:47
Commented: Star Strider
on 8 Apr 2024 at 16:03
I need to create a surface plot showing how SKL varies with both Pec and QBERI, but because this is a data set, it is not a function of either of them. Every resource I can find online about this requires the z variable to depend on the x and y, so I've been running into a lot of issues.
1 Comment
Adam Danz
on 5 Apr 2024 at 17:02
How many Pec values are there there? If there are only 4, then a surface plot doesn't seem like the right tool.
I don't see enough of the data to understand whether this suggestion makes sense but why not plot 4 line objects that each have their own Pec label?
hold on
plot(QBERI_1, SKL_1,'.','DisplayName','Pec=1.00E-06')
plot(QBERI_2, SKL_2,'.','DisplayName','Pec=7.00E-07')
plot(QBERI_3, SKL_3,'.','DisplayName','Pec=4.00E-07')
plot(QBERI_4, SKL_4,'.','DisplayName','Pec=1.00E-07')
legend()
Accepted Answer
Star Strider
on 5 Apr 2024 at 17:49
It would help to have the spreadsheet.
The data can be extracted from it using either table or matrix indexing, once it is immported.
That result needs to create an array like this —
A = [NaN 1E-06 7E-7 4E-7 1E-7
1E-3 2.17E-8 2.18E-8 2.20E-8 2.21E-8
7E-4 2.21E-8 2.23E-8 2.24E-8 2.26E-8
4E-4 2.26E-8 2.27E-8 2.26E-8 2.31E-8
1E-4 2.31E-8 2.32E-8 2.34E-8 2.36E-8];
figure
surfc(A(2:end,1), A(1,2:end), A(2:end, 2:end))
colormap(turbo)
colorbar
xlabel('QBERI')
ylabel('Pec')
zlabel('SKL')
view(60,30)
Then creating the surface or contour plot (or both) is straightforward.
.
2 Comments
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!