MATLAB Answers


2d slice of 3d function giving weird results

Asked by J K
on 5 Jun 2019
Latest activity Commented on by Rena Berman on 19 Sep 2019 at 17:36
Hi fellows. I sliced a 3d function called ''absolute'' and it gave me weird results. I do not think this is how it is supposed to look.


Guillaume, I do not agree that the conversation degenerated - it was harsh and unpleasant, the picture sketched of the OP was not flattering, and I did not show myself from the best side either, but everything in this world doesn't smell of roses.
The discussion veered off the original question into the much more generally important question of how an online forum like this can/should/could and cannot/shouldn't be used in learning. The way I judged the initial question it was for a programming task in signal processing/application of Fourier methods and the problem the OP had was related to matlab-specific programming techniques - something that he or she might have aske the TA or a fellow student about and gotten roughly identical advice as was given here. In my (rather pragmatic) view on learning it doesn't matter much how students develop their skills in a secondary learning objective like (matlab-)programming in a course where that is a secondary objective - if I found any of my students asking a similar question here I would monitor the discussion. If the advice was only on the level of programming technicallities I would deem that OK, if they somehow managed to get a ready-to-run solution without much (or any) effort I would have problems. Other issues might also arise.
You have the right to moderate the discussion and did so to the best of your judgement, I don't necessarily agree with that moderationing, but I've surely agreed to that in one or the other of the terms and conditions...
There's certainly value in discussing "how an online forum like this can/should/could and cannot/shouldn't be used in learning" but that's worthy of its own discussion in its own question.
Here, it's not going to achieve anything other than anger both sides. While you can guess which side I agree with, I don't see much point in arguing any further. It's unlikely that the other side will change its tone.
On the general topic of moderation, anybody with the required reputation (3000, not even MVP) can delete anything they want. It's obviously not something I like to do. In this instance, I've gone by what mathworks have done in previous occasions which was to delete the entire conversation.
(Answers Dev) Restored edit

Sign in to comment.




1 Answer

Answer by Bjorn Gustavsson on 6 Jun 2019
 Accepted Answer

Why not?
From what it seems you have a 3-D Gaussian, you FFT that, fftshift it, and take the absolute value of the Fourier-transform of the 3-D Gaussian. Why wouldn't it look like that (approximately, difficult to check details from the image...)
That slice by default uses "faceted shading" is something you can change by issuing something like:
shading flat % or
shading interp
just after your slice call.


The only thing I can see is that your function ftointeg is intependent of the input arguments, and will return the full matrix absolute for any combination of input arguments regardless of what values they have - so most likely not what you want to have there for integration.
Like this:
fcn_sin = @(x) sin(x);
D2d = peaks(123);
x = 1:size(D2d,1);
y = 1:size(D2d,2)
fcn_peaks = @(xi,yi) interp2(x,y,D2d,x,y,'cubic');
Read the documentation of that and test and try a few different things.

Sign in to comment.