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

13 ビュー (過去 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 Center および File ExchangeScatter Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by