Representing data as surface
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, I am trying to plot a surface from my data (x,y,z). I have a collection of data with the following (X, Y, Z) triplets:
I have represented x, y and z in the form of matrix (as shown in my code below) and I have tried to represent the values of z with respect to x and y and that s what i have found as result:
The result is not correct, I wanted to have the 25 values of z represented each one in a specific color.
for example for x=1 and y=25, i want to have a colored surface that represent z= 0.192678 and the same thing for all the others.
(with stem3, it s ok, i have my 25 vertices but i want to obtain 25 colored surfaces)
This is my code and data:
close all
clear all
x=[1 1.02 1.06 1.08 1.1 ;1 1.02 1.06 1.08 1.1; 1 1.02 1.06 1.08 1.1;1 1.02 1.06 1.08 1.1;1 1.02 1.06 1.08 1.1];
y=[25 25 25 25 25; 28 28 28 28 28; 30 30 30 30 30; 35 35 35 35 35; 40 40 40 40 40];
z=[0.1926782273603 25.7666609559705 26.3758732322372 17.0874435713091 2.61780104712041;...
0.50550640909912 25.1708618103017 33.1627906976744 7.59717314487632 0.342836521111504 ;...
1.23900161608907 25.8307914593033 41.9949352841868 32.1646341463415 4.74541046068583 ;...
0.274630964641264 25.831399845321 49.0575458744227 20.4442361761949 22.8672566371681 ;...
2 28.1091559797196 33.3518005540166 18.3106367316894 24.7384937238494 ];
figure
% stem3(x,y,z)
surf(x,y,z)
% shading flat
colormap jet
Any help would be strongly appreciated.
Thank you in advance
0 commentaires
Réponses (1)
Star Strider
le 3 Août 2019
See if adding
view(20, 20)
after your surf call does what you want.
4 commentaires
Star Strider
le 3 Août 2019
My pleasure.
THe surf plot creates a surface, so it does what you say you want.
I have no idea what you want, so:
Try this:
figure
surf(x,y,z)
view(20, 20)
shading('interp')
colormap jet
or this:
[X,Y] = meshgrid(1:0.01:1.1, 25:0.25:40);
Z = griddata(x, y, z, X, Y, 'cubic');
figure
surf(X, Y, Z)
view(20, 20)
shading('interp')
colormap jet
to see if those are what you want. Note that the second just interpolates to a finer grid, and uses a cubic interpolation function.
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!