Creating a 3D surface plot from a data of 3 variables and 1 response

4 次查看(过去 30 天)
Based on the below data, how can I create a surface plot with a colorbar for the response given data below: Hoping for your kind help!
A=[195 65 195 65 195 65 195 65]; %parameter 1
B=[120 120 150 150 120 120 150 150]; %parameter 2
C=[2 2 2 2 1 1 1 1]; %parameter 3
Y=[527 570 537 549 728 780 725 748]; %response
I have made a code below that represents a scatter plot, however, I wanted to know how I can do a surface plot with the response represented in the colorbar. Hoping for someone's help.
clc;
close all;
A=[195 65 195 65 195 65 195 65]; %parameter 1
B=[120 120 150 150 120 120 150 150]; %parameter 2
C=[2 2 2 2 1 1 1 1]; %parameter 3
Y=[527 570 537 549 728 780 725 748]; %response
scatter3(A,B,C,8,Y,'filled') % draw the scatter plot
ax = gca;
ax.XDir = 'reverse';
view(-31,14)
xlabel('Parameter 1')
ylabel('Parameter 2')
zlabel('Parameter 3')
cb = colorbar; % create and label the colorbar
cb.Label.String = 'Response';

回答(1 个)

Benjamin Campbell
Benjamin Campbell 2022-11-4
You are trying to represent 4 dimensions which you can do in 3 spatial dimensions, and the fourth dimension colour. If you wanted it to be more like a surface plot it would have to be a cube of continuous colour changes which is impossible to see.
I would recommend breaking the data up into two surface plots and using:
https://ch.mathworks.com/help/matlab/ref/surf.html

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by