Help Smoothing MATLAB 3D Graphs

In summary, the conversation is about a person asking for help with smoothing 3D graphs made in MATLAB. They provide their code and explain that there are some weird peaks in the graph that they believe should be smoother. They ask if there is a way to smooth 3D graphs in MATLAB and mention their limited English skills. The expert summarizer then provides four suggestions for smoothing the graphs, including increasing the number of points in the meshgrid, using the "interp" function, using the "smoothdata" function, and trying the "sgolayfilt" function.
  • #1
Radinax
12
0
Hello everybody.

I need help with smoothing 3D graphs made in matlab. I have the following code

%Simulacion
%Declarando variables
I=500; %Corriente
a=2; %Radio
h=8; %Altura
h2=12; %Altura 2
u=1.2566e-006; %permeabilidad magnetica
w=6.832; %2*pi
>> Ke=9*10^9;
>> x=(-15:0.1:15);
>> y=(0:0.1:15);
>> [X,Y]=meshgrid(x,y);

>> %CASO CAMPO ELECTRICO
>> %Dos cables
>> Exx=Ke*(10^-6)*((((X+a)./((X+a).^2+(Y-h).^2+eps))-((X+a)./((X+a).^2+(Y+h).^2+eps)))-(((X-a)./((X-a).^2+(Y-h).^2+eps))-((X-a)./((X-a).^2+(Y+h).^2+eps))));
>> Eyy=Ke*(10^-6)*((((Y-h)./((X+a).^2+(Y-h).^2+eps))-((Y+h)./((X+a).^2+(Y+h).^2+eps)))-(((Y-h)./((X+a).^2+(Y-h).^2+eps))-((Y+h)./((X+a).^2+(Y+h).^2+eps))));
>> E3D2=sqrt(Exx.^2+Eyy.^2); %CAMPO ELECTRICO TOTAL
>> surfc(X,Y,E3D2)

When i graph it, there are some weird peaks, this is the electric field of two power lines in horizontal in 10 meters of heigth, located at a/-a distance from each other. I am doing to for three lines (the graph gets worse). I think the top of the peak supossed to be more smooth, because when i use contour, you can see some rhombus, and it supossed to be a circles. Is there a way to smooth 3d graphs in MATLAB?

PS: My english isn to good so i apologize if i wrote something wrong or bad spelled.
 
Physics news on Phys.org
  • #2


Hello!

Thank you for posting your question on the forum. It seems like you are having trouble with your 3D graphs in MATLAB and are looking for a way to smooth them out. There are a few ways you can go about doing this. Here are some suggestions:

1. Increase the number of points in your meshgrid. This will create a denser grid and can help smooth out the peaks in your graph.

2. Use the "interp" function to interpolate your data onto a finer grid. This can also help smooth out the peaks in your graph.

3. Use the "smoothdata" function in MATLAB. This function allows you to smooth your data using different methods such as moving average or Savitzky-Golay filter.

4. If you are using MATLAB R2019b or later, you can try using the "sgolayfilt" function which applies a Savitzky-Golay filter to your data.

I hope these suggestions help you in smoothing out your 3D graphs. Let me know if you have any further questions. Good luck with your research!
 

1. How can I make my 3D graph in MATLAB look smoother?

To make your 3D graph in MATLAB look smoother, you can increase the number of data points used to create the graph. This will result in a more detailed and smoother plot. You can also try using different interpolation methods or adjusting the resolution of your graph.

2. What is the purpose of smoothing a 3D graph in MATLAB?

The purpose of smoothing a 3D graph in MATLAB is to reduce any noise or fluctuations in the data and make the overall trend or pattern more visible. This can help in better understanding and analyzing the data.

3. Can I smooth only a specific part of my 3D graph in MATLAB?

Yes, you can smooth only a specific part of your 3D graph in MATLAB by selecting the desired portion of the graph and then applying a smoothing function or interpolation method to it. This can be useful if you want to focus on a particular area of the data.

4. Is there a specific function in MATLAB for smoothing 3D graphs?

Yes, there are several functions in MATLAB that can be used for smoothing 3D graphs, such as the smoothdata function, interp1 function, and the sgolayfilt function. Each of these functions has its own parameters and can be used for different types of data.

5. Will smoothing my 3D graph in MATLAB change the actual data values?

No, smoothing a 3D graph in MATLAB will not change the actual data values. It will only change the way the data is displayed on the graph, making it appear smoother and more visually appealing. The original data will remain unchanged.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
12K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Advanced Physics Homework Help
Replies
6
Views
2K
Back
Top