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!