Considering the plots below, I have a problem in adding an extra dimension to a 1D rectangular pulse train. In other words, I am trying to implement a 3D grating in matlab, as shown below. Any help would be appreciated!

 Accepted Answer

I think this is what you're looking for
x = [1 2 2 3 3 4 4 5 5 6];
z = [0 0 1 1 0 0 1 1 0 0];
y = [1 4];
[X,Y] = meshgrid(x,y)
Z = repmat(z,[length(y) 1])
surf(X,Y,Z,'FaceColor',[0.5 0.5 0.5])

6 Comments

you can use "3d rotate" button to change view angle.
Hi. That is a great method and thanks for proposing the approach.
However, given that I need to obtain the Fourier transform of this graph, expressing it by a specific function would be nice.
Based on this code, I tried to consider "Z" as a fundamental equation to obtain the Fourier transform through the code below, however, I am not sure if the result is correct. Any suggestion?
y=fftshift(fft(Z));
N=length(y);
n=-(N-1)/2:(N-1)/2;
f=sqrt(y.*conj(y));
title('Rectangular pulse amplitude');
xlabel('frequency component(harmoney)');
ylabel('Amplitude of the harmoney');
plot(n,f);
axis([-5000 5000 5 5]);
hello again Mr. Ahmadivand. No ofcourse this was just a graphic show of 3d object. in order to use fft first you must collect sampled data in constant intervals by a specific sampling frequency. however the pulse train function fourier transform is easily calculated analytically. I suggest you only program the solution for which the function recieves input arguments like amplitude, period, pulse width and number of harmonic and outputs the hormonic amp and phase angle. if you don't want to bother, refer to "advanced engineering mathematic,kreizig". there's the formula of pulse train fourier series.
Arash A.
Arash A. on 12 Aug 2020
Hi Hosein. Thanks so much for the previous guidance and also showing the potential solution.
پاینده باشید. اگر امر دیگری بود در خدمتتونم
Sure, thanks so much for your help.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!