Calculate and Plot Fourier function
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi there,
I have made some calculation on paper and would like to visualise the result by plotting it in MATLAB. However I can't seem to get result that I expect. I have attached a screenshot of the function and the code that I have until now. I would very much appreciate some help on with this.
%
clear;
clc;
%
Fs = 10000000; % samples per second
dt = 1/Fs; % seconds per sample
StopTime = 0.01; % seconds
t = (0:dt:StopTime-dt)'; % seconds
%
n = 1:50;
%
Fm = 1e3; %Signal frequency for omega(m).
Fc = 100e3; %Signal frequency for omega(c).
Am = 1/10;
Ac = 5/10;
%
A1 = Am*Ac/2*(sin(2*pi*Fc*t));
A2 = Am*Ac/pi;
A3 = A1-A2;
A4 = cos(n*2*pi*Fm*t-2*pi*Fc*t);
A5 = cos(n*2*pi*Fm*t+2*pi*Fc*t);
%
A6 = A3-1/n*((A4-A5));
%
댓글 수: 0
답변 (1개)
nanren888
2017년 4월 1일
편집: nanren888
2017년 4월 1일
>> tmp01 Error using * Inner matrix dimensions must agree.
Error in tmp01 (line 17) A4 = cos(n*2*pi*Fm*t-2*pi*Fc*t);
>>
Is this what you mean?
Posting the error will help people see where you are & give you an answer that is useful to you. . The error appears because n is a row vector ([50,1]) & t is a column ([100000,1]) You tell Matlab to do the multiply n*...*t & the inner dimensions don't match. (Which they shouldn't)
Did you intend to an outer product? to create a resulting matrix ([50,100000])? or perhaps its transpose?
If so, transposing each of them might help, or swapping the order of the multiplications?
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!