how to plot gaussian filter using meshgrid Function
9 次查看(过去 30 天)
显示 更早的评论
![](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 个评论
Jan
2017-7-24
编辑:Jan
2017-7-24
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
2021-2-21
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.
采纳的回答
John BG
2017-7-23
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 个评论
Jan
2017-7-24
@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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Axis Labels 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!