Filter command for contour plot MATLAB

In summary: Your Name]In summary, Alex has shared a BSFC plot and the code used to create it. They are now looking for ways to use the filter function to smooth out the curves in the plot. Some suggestions are to apply the filter function directly to the data before plotting or to use the "smoothdata" function in MATLAB.
  • #1
Alex91
7
0
Hi all,

I have made a BSFC plot in MATLAB with engine data tested on an eddie current dyno, The code I used for it is:

>> NP=40;
>> [RP TP]=meshgrid(linspace(min(RPM),max(RPM),NP),linspace(min(Torque),max(Torqu e),NP));
>> BSFC_IT=griddata(RPM,Torque,BSFC,RP,TP);
>> NC=12;
>> Fig1=figure;
>> [CT HT]=contourf(RP,TP,BSFC_IT,round(logspace(log10(210),log10(400),NC)));
>> colorbar;
>> %clabel(CT,HT);
>> xlabel('Engine Speed (rpm)')
>> ylabel('Torque (Nm)')
>> title('Contours of BSFC (g/kWh)')

With all my data this gave me a contour plot that looks like the image I have attached and this is after fiddling with all of the data to make it look 'pretty'.

I know you can use the filter function to smooth out plots, so my question is, how can I use the filter function to smooth out the curves with the complex code I have?

Any help is much appreciated.

Thanks

Alex
 

Attachments

  • Contour Plot.png
    Contour Plot.png
    14.4 KB · Views: 984
Physics news on Phys.org
  • #2


Hello Alex,

Thank you for sharing your BSFC plot and the code you used to create it. It looks like you have already put a lot of effort into making it visually appealing. As for using the filter function to smooth out the curves, there are a few things you can try.

First, you can try applying the filter function directly to the data before plotting it. This would involve replacing the line "BSFC_IT=griddata(RPM,Torque,BSFC,RP,TP);" with something like "BSFC_IT_filtered=filter(1,10,BSFC_IT);" where the numbers "1" and "10" can be adjusted to change the level of smoothing.

Another option is to use the "smoothdata" function in MATLAB. This function allows you to specify the type of smoothing you want (such as moving average or Savitzky-Golay) and the amount of smoothing you want to apply. You can find more information about this function in the MATLAB documentation.

I hope this helps! Let me know if you have any other questions. Good luck with your research.
 

Related to Filter command for contour plot MATLAB

1. What is the purpose of the filter command for contour plot in MATLAB?

The filter command in MATLAB is used to smooth out data and reduce noise in a contour plot. It allows for better visualization of patterns and trends in the data.

2. How do you use the filter command in MATLAB for a contour plot?

To use the filter command for a contour plot in MATLAB, you must first have a matrix of data. Then, you can use the filter function to specify the type of filter and the size of the filter window. Finally, you can apply the filter to the data and plot the results.

3. What types of filters can be used with the filter command in MATLAB?

The filter command in MATLAB allows for a variety of filters to be used, including moving average, median, Gaussian, and more. These filters can be adjusted to different sizes and strengths to achieve the desired level of smoothing in the contour plot.

4. Can the filter command be applied to 3D contour plots in MATLAB?

Yes, the filter command can be applied to 3D contour plots in MATLAB. However, the filter will only be applied to the data in the x-y plane, as the z-axis represents the height or value of the data point and should not be smoothed.

5. Are there any downsides to using the filter command for contour plots in MATLAB?

One potential downside of using the filter command for contour plots in MATLAB is that it can alter the original data and potentially remove important details. It is important to carefully select and adjust the filter to avoid losing important information in the data.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
6K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
6K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Calculus and Beyond Homework Help
Replies
11
Views
11K
Back
Top