how to plot gaussian filter using meshgrid Function
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Khalid Khan
el 22 de Jul. de 2017
Comentada: Sonny Revell
el 21 de Feb. de 2021
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/166231/image.png)
To plot a function of two variables, you need to generate u and v matrices consisting of repeated rows and columns, respectively, over the domain of the function H and D. Use Matlab documentation to learn about the meshgrid function, and then use it to define u and v.
2 comentarios
Jan
el 24 de Jul. de 2017
Editada: Jan
el 24 de Jul. de 2017
This looks like a homework question. If this is true, please mention this, because the another type of answers is required. 1. Submitting a solution given by someone else might be treated as cheating in your university. 2. The question contains " Use Matlab documentation to learn", and providing a solution will not support this.
Note that the reputation of this forum suffers, if the members post solutions of homeworks. Then no serious teacher will recommend to use this forum anymore. But it is another story, if you post, what you have tried so far and ask a specific question. Then the forum can assist you to solve your problem by your own.
Sonny Revell
el 21 de Feb. de 2021
I feel differently. Often times the instructors are not clear or understandable and we have to "learn on our own" from examples. The obscure lecture topic became clear from the examples from this forum. You Jan have "filled in the blanks" many times for me. Perhaps you should ask the instructors to be clear on the topics. Thanks Jan.
Respuesta aceptada
John BG
el 23 de Jul. de 2017
Hi Khalid
1.
generating U and V with meshgrid
N=4;M=4;dN=.01;dM=.01;
[U,V]=meshgrid([-N:dN:N],[-M:dM:M]);
2.
the signal
s=10;
H=exp(-1/s^2*((U-N/2).^2+(V-M/2).^2));
2.
plotting
hs=surf(U,V,H);hs.EdgeColor='none'
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/177544/image.jpeg)
.
note I have extended the plot limits to [-N N] and [-M M], since the question reads [1 N] [1 M] the plot would be just a quarter 'chunk' of the cake, not including the peak
.
if you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance
John BG
2 comentarios
Jan
el 24 de Jul. de 2017
@Khalid Khan: You draw the text at z=1.25, but the Z-axis limit is at 1.0. You can use the zlim commadn to adjust this, but it looks strange that "the peak location specified by the point (N/2,M/2,1.25)" does not seem to match the current value.
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!