17 views (last 30 days)
Show older comments
WJ on 12 Aug 2020
Answered: EE_student on 19 Jun 2021
My Question in the title, i am new to matlab and i need help with this please
0 Comments Show -2 older commentsHide -2 older comments
Show -2 older commentsHide -2 older comments
Sign in to comment.
Sign in to answer this question.
Answers (4)
Sulaymon Eshkabilov on 12 Aug 2020
Hi,
Here are several nice tutorial examples of matlab on Fourier Transform.
https://www.mathworks.com/help/matlab/math/fourier-transforms.html
0 Comments Show -2 older commentsHide -2 older comments
Show -2 older commentsHide -2 older comments
Sign in to comment.
Star Strider on 12 Aug 2020
My impression is that this is homework. We give hints for homework, not complete code. (You must write the code. We will help you to get your code to run if you have problems with it.)
It is straightforward to compute the Fourier transform symbolically. You need to remember also to allow for the part of the signal that is zero in the time range that you are computing it.
You already discovered Hi how do i plot a halfwave rectifier signal in matlab? i tried the coding below and only got the fullwave (since you posted a Comment to it to request thatI look at this Question), all you then need to do is to read the documentation for fft and use that with the signal I provided in that Answer.
9 Comments Show 7 older commentsHide 7 older comments
Show 7 older commentsHide 7 older comments
WJ on 12 Aug 2020
Direct link to this comment
https://support.mathworks.com/matlabcentral/answers/578715-how-to-compute-the-complex-fourier-series-expansion-of-half-wave-rectified-signal-and-plot-its-phas#comment_970044
its actually not a homework, i am trying to check the amplitude and the phase, for my own study, but i never used matlab before and idont even know how to code, i know the coefficants of the series and the idea of phasing, but i dont know how to use this app thats why i am asking for some help, please help me and thanks
WJ on 12 Aug 2020
Direct link to this comment
https://support.mathworks.com/matlabcentral/answers/578715-how-to-compute-the-complex-fourier-series-expansion-of-half-wave-rectified-signal-and-plot-its-phas#comment_970047
and the thing is that i dont even have the function of the half wave rectified so i can use fft
Star Strider on 12 Aug 2020
Direct link to this comment
https://support.mathworks.com/matlabcentral/answers/578715-how-to-compute-the-complex-fourier-series-expansion-of-half-wave-rectified-signal-and-plot-its-phas#comment_970113
In that instance, use the second part of my Answer and plot the fft of the half-wave rectified signal.
The table that you posted appears to require a context that is not provided.
WJ on 12 Aug 2020
Direct link to this comment
https://support.mathworks.com/matlabcentral/answers/578715-how-to-compute-the-complex-fourier-series-expansion-of-half-wave-rectified-signal-and-plot-its-phas#comment_970128
i am trying to
f=50;
t=linspace(0,30,500);
x=sin(2*pi*f*t);
rect_sig = sig > 0;
y = fft(x);
f = (0:length(y)-1)*50/length(y);
plot(f,abs(y))
title('Magnitude')
subplot(221)
stem(t,abs(sig))
i cant get the amplitude spectra
it should be straight lines, any help?
WJ on 12 Aug 2020
Direct link to this comment
https://support.mathworks.com/matlabcentral/answers/578715-how-to-compute-the-complex-fourier-series-expansion-of-half-wave-rectified-signal-and-plot-its-phas#comment_970134
i fixed it a little bit
l=linspace(0,10,100);
sig=sin(2*pi*50*l);
subplot(211)
plot(sig);
grid
% u=1:9;
% t=(1:)
for t=1:100
if sin(2*pi*50*l(t))<=0
sig(t)=0;
else
sig(t) = sin(2*pi*50*l(t));
end
end
subplot(212)
plot(sig);
grid
stem(l,abs(sig),'b')
still cant get straight lines
whats the issue?
Star Strider on 12 Aug 2020
Direct link to this comment
https://support.mathworks.com/matlabcentral/answers/578715-how-to-compute-the-complex-fourier-series-expansion-of-half-wave-rectified-signal-and-plot-its-phas#comment_970158
Open in MATLAB Online
Try this slightly modified version of your code:
f=50;
t=linspace(0,30,500);
Fs = 1/(t(2)-t(1));
Fn = Fs/2;
sig=sin(2*pi*f*t);
rect_sig = sig.*(sig > 0); % Half-Wave Rectification
y = fft(rect_sig)/numel(sig);
f = linspace(0, 1, fix(numel(sig)/2)+1)*Fn; % Frequency Vector
idx = 1:numel(f); % Index Vector
% f = (0:length(y)-1)*50/length(y);
figure
subplot(2,1,1)
semilogy(f,abs(y(idx))*2)
title('Magnitude')
grid
subplot(2,1,2)
plot(f,unwrap(angle(y(idx))))
title('Phase')
grid
figure
% subplot(221)
stem(t,rect_sig)
.
WJ on 12 Aug 2020
Direct link to this comment
https://support.mathworks.com/matlabcentral/answers/578715-how-to-compute-the-complex-fourier-series-expansion-of-half-wave-rectified-signal-and-plot-its-phas#comment_970176
how can i change the magnitude to amplitude?
i know i made trouble for you but i reaLLY APPRECIATE IT
WJ on 12 Aug 2020
Direct link to this comment
https://support.mathworks.com/matlabcentral/answers/578715-how-to-compute-the-complex-fourier-series-expansion-of-half-wave-rectified-signal-and-plot-its-phas#comment_970179
Edited: WJ on 12 Aug 2020
how can i make the amplitude and phase look like this? as straight lines
or is it just like this when n= a constant number?
Star Strider on 12 Aug 2020
Direct link to this comment
https://support.mathworks.com/matlabcentral/answers/578715-how-to-compute-the-complex-fourier-series-expansion-of-half-wave-rectified-signal-and-plot-its-phas#comment_970230
Open in MATLAB Online
To get the amplitude (amplitude = magnitude) spectrum such as in the plot image, use the fftshift function, then plot using a symmetric frequency vector, for example:
sy = fftshift(y);
sf = linspace(-10,10, numel(sy));
then:
figure
stem(sf, sy)
or something similar.
Sign in to comment.
Swapnil Khot on 8 May 2021
How we write code for half wave rectifier using Fourier series
0 Comments Show -2 older commentsHide -2 older comments
Show -2 older commentsHide -2 older comments
Sign in to comment.
EE_student on 19 Jun 2021
Wait have you sorted it out?
0 Comments Show -2 older commentsHide -2 older comments
Show -2 older commentsHide -2 older comments
Sign in to comment.
Sign in to answer this question.
See Also
Categories
MATLAB
Find more on MATLAB in Help Center and File Exchange
Tags
- fourier series
- complex series
- matlab
- spectra
- amp
- amplitude
- half wave rectified signal
Products
- MATLAB
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
Contact your local office