how to plot gaussian filter using meshgrid Function
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Khalid Khan
am 22 Jul. 2017
Kommentiert: Sonny Revell
am 21 Feb. 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 Kommentare
Jan
am 24 Jul. 2017
Bearbeitet: Jan
am 24 Jul. 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
am 21 Feb. 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.
Akzeptierte Antwort
John BG
am 23 Jul. 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 Kommentare
Jan
am 24 Jul. 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Axis Labels finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!