How to draw the graph by using MATLAB which consists of 3variable and 2 results.

How to draw the graph by using MATLAB which consists of 3variable and 2 results. I had attach my data in excel below.
Surface graph or 3D graph or any other graph that you all recommended for this results.
Thanks in advance.

 Accepted Answer

This shows how to visualize 4D data using slice(). Since you have two output variables, it is visualized in separate figures.
data = readmatrix('dac.xlsx');
x = data(:,1);
y = data(:,2);
z = data(:,3);
Ef = data(:,4);
C = data(:,5);
[xg,yg,zg] = meshgrid(unique(x), unique(y), unique(z));
Efg = griddata(x,y,z,Ef, xg,yg,zg); % arranging Eg as a grid
Cg = griddata(x,y,z,C, xg,yg,zg); % arranging C as a grid
%% visualize 4D data as slices
% visualize Ef
figure();
slice(xg,yg,zg,Efg, [50 70],[2 3],[270 300 330]) % visualize data at specifc planes
figure();
slice(xg,yg,zg,Cg, [50 70],[2 3],[270 300 330]) % visualize data at specifc planes
Electric field:
Cost:

7 Comments

Thank you ! One question..
Why i getting this error ?
Undefined function or variable 'readmatrix'.
It seems that you are using an older version of MATLAB. Change first line to this
data = xlsread('dac.xlsx');
This code shows how you can set the coordinates of axis location.
data = readmatrix('model2variable3.xlsx');
x = data(:,1);
y = data(:,2);
z = data(:,3);
xu = unique(x);
yu = unique(y);
zu = unique(z);
Ef = data(:,4);
C = data(:,5);
[xg,yg,zg] = meshgrid(xu, yu, zu);
Efg = griddata(x,y,z,Ef, xg,yg,zg); % arranging Eg as a grid
Cg = griddata(x,y,z,C, xg,yg,zg); % arranging C as a grid
%% visualize 4D data as slices
% visualize Ef
figure();
slice(xg,yg,zg,Efg, [xu(2) xu(end-2)],[yu(2) yu(end-2)],[zu(2) zu(end-2)]) % visualize data at specifc planes
figure();
slice(xg,yg,zg,Cg, [xu(2) xu(end-2)],[yu(2) yu(end-2)],[zu(2) zu(end-2)]) % visualize data at specifc planes
Thank you.
I had inbox you one question, can you check on it ?
Hi Ameer,
I had inbox you another question, can you check on it ? Thank you !

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!