4D plot with matlab

9 views (last 30 days)
Shirin Muhammad
Shirin Muhammad on 1 Apr 2019
Commented: Adam Danz on 5 Apr 2019
I have the attached data, in which the first three columns are variables, the fourth column data was obtained as a function of the variables c1,c3, and c4.
Can any one tell me how I can plot them together?
Thank you.

Answers (2)

Adam Danz
Adam Danz on 1 Apr 2019
Edited: Adam Danz on 2 Apr 2019
It sounds like you've got data (stored in column 4) that vary on 3 axes (stored in cols 1:3). Perhaps a 3D contour plot or a 3D surface plot can be used where the (x,y,z) coordinates are defined by your columns 1,2,3 and the color is defined by the data in column 4. Check out the documentation for those functions and let us know if you get stuck.
Another option is to use a 3D scatter plot and color each marker according to the value in the 4th dimension.
figure
h = scatter3(data(:,1), data(:,2), data(:,3), 20, data(:,4), 'MarkerFaceColor', 'Flat');
colorbar();
caxis([min(data(:,4)), max(data(:,4))])
  18 Comments
Shirin Muhammad
Shirin Muhammad on 5 Apr 2019
Edited: Shirin Muhammad on 5 Apr 2019
Is there any one who can help me by ploting the data data1.png using contour3?
thanks
Adam Danz
Adam Danz on 5 Apr 2019
After recommending contour3() I realized this isn't really an option since it only receives (X,Y,Z) values. My initial thought was to change the colors to your values in the 4th column but I'm no longer sure that's possible. I looked at the 2nd output to contour3() which is the handle to the plot and it wasn't immediately apparent how to access and change the color values.

Sign in to comment.


Shirin Muhammad
Shirin Muhammad on 2 Apr 2019
I don't have any preference to use contour3 . My data is attached. thank you for your time.

Community Treasure Hunt

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

Start Hunting!