Creating a 3D surface plot from a data of 3 variables and 1 response
조회 수: 3 (최근 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';
댓글 수: 0
답변 (1개)
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!