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

조회 수: 3 (최근 30일)
lvenG
lvenG 2022년 11월 4일
댓글: Benjamin Campbell 2022년 11월 14일
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
  댓글 수: 2
lvenG
lvenG 2022년 11월 5일
However, my z (represented as C) is not a matrix but is a scalar (represented by the given data).
Benjamin Campbell
Benjamin Campbell 2022년 11월 14일
It is a 2 x 2 x 2, it has just been put in as a vector.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by