problem with graphics to use surf()
1 view (last 30 days)
Show older comments
Denis Alberto Castro Rodriguez
on 25 Apr 2019
Commented: Denis Alberto Castro Rodriguez
on 26 Apr 2019
Hi all,
I am trying to create the graphics using the surf () command but it is generating an additional surface, as if I were joining the starting point with the end
The expression that I am using is this
clc
clear all
x1=load('potencial.txt');
x2=load('velocidad.txt');
x3=load('temperatura.txt');
cor1=x1(:,1);
cor2=x1(:,2);
poten=x1(:,3);
poten_anal=x1(:,4);
vel=x2(:,3);
vel_anal=x2(:,4);
temp = x3(:,3);
temp_anal = x3(:,4);
nn = length(poten);
[X,Y]=meshgrid(cor1,cor2);
Tpot=griddata(x1(:,1),x1(:,2),x1(:,3),X,Y,'cubic');
Tvel=griddata(x2(:,1),x2(:,2),x2(:,3),X,Y,'cubic');
Ttemp=griddata(x3(:,1),x3(:,2),x3(:,3),X,Y,'cubic');
figure (1)
surf(X,Y,Tpot)
title('Potencial')
figure (3)
surf(X,Y,Tvel)
title('Velocidad')
figure (4)
surf(X,Y,Ttemp)
title('Temperatura')
As you can see, an additional blue surface is plotted, which is not why it is generated.
It would be very helpful if you could help me with this.
4 Comments
Accepted Answer
Walter Roberson
on 26 Apr 2019
cor2 is periodic. It ends up starting and ending at 0. You use it to form the Y coordinates, and in so doing accidentally ask the plot to return to y = 0 .
I recommand
N = 50; %how refined
cor1 = linspace( min(x1(:,1)), max(x1(:,1)), N);
cor2 = linspace(min(x1(:,2)), max(x1(:,2)), N);
More Answers (0)
See Also
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!