Plot 4d Using meshgrid

5 ビュー (過去 30 日間)
Leonardo Barbosa Torres dos Santos
Leonardo Barbosa Torres dos Santos 2019 年 10 月 18 日
コメント済み: alok dhaundiyal 2020 年 11 月 18 日
Dear, could someone help me please?
I have a file with 4 column.
I would like plot a graphic 4D, where the axis x, y and z are the column from 1 to 3, respectively, and the color code is the column 4.
I built a graphic, is attached, but I would like make a surface. I read it is possible using mesh comand. But I could not.
Thank you advanced

回答 (2 件)

Soham Chakraborty
Soham Chakraborty 2019 年 10 月 21 日
Hi,
As per my understanding you are able to create a 3-D plot. However, you need guidance in representating an additional column of data using color codes. The above requirement can be sovled using 'mesh' or 'surf' command (for creating mesh or surface plot).
The following example could help you with your requirement:
[X,Y] = meshgrid(-8:.5:8);
Z = sin(X) + cos(Y);
C = X.*Y;
mesh(X,Y,Z,C);
or
[X,Y] = meshgrid(-8:.5:8);
Z = sin(X) + cos(Y);
C = X.*Y;
surf(X,Y,Z,C);
  1 件のコメント
alok dhaundiyal
alok dhaundiyal 2020 年 11 月 18 日
incorrect

サインインしてコメントする。


Leonardo Barbosa Torres dos Santos
Leonardo Barbosa Torres dos Santos 2019 年 10 月 21 日
編集済み: Leonardo Barbosa Torres dos Santos 2019 年 10 月 24 日
Dear, I tried use your sugestion. But the matlab show me an error:
"Error using mesh (line 71)
Z must be a matrix, not a scalar or vector."
The z-axis is the third column of my file. I believed that it was a matrix with n lines and 1 column and not a vector or scalar.
Below I am puting my code to you see. Could you help me ? Because I don't know how solve it.
clc,clear all,format long
point = load ('general_resultosA.dat') ; % load data
long = point(:,1); % longitude data
lat = point(:,2); % latitude data
rural = point(:,3); % percent rural data
fatalities = point(:,4); % fatalities data
xlabel('\Phi [deg]')
ylabel('\mu [adim]')
zlabel('k')
xlim([0 75])
ylim([0.5 0.9])
zlim([1 9])
mesh(long,lat,rural,fatalities);

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by