how can I turn my .m file into C?

2 ビュー (過去 30 日間)
Kay Wonderley
Kay Wonderley 2018 年 3 月 25 日
編集済み: Walter Roberson 2018 年 3 月 28 日
I have an involved script file which runs. I have tried to turn it into C with the Matlab coder App. It is asking for a function, and hence and when I load this file it does not except it saying it is a script. but it wants a function. Could somebody give me some pointers?
  2 件のコメント
Hans Scharler
Hans Scharler 2018 年 3 月 27 日
What are you building?
Kay Wonderley
Kay Wonderley 2018 年 3 月 28 日
編集済み: Walter Roberson 2018 年 3 月 28 日
Hi Hans,
I am building a filtered-X-least mean square filter for active noise cancellation of power transformer.
so there is are several functions in the code that I have been given.
my problem is:
being new to program and trying to work out the inputs and outputs of this code:
here is part of it. it is a filtered X-LMS for active noise cancellation.
Fs = 2000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 4000; % Length of signal
t = (0:L-1)*T; %time
A=[16 18 28 33 38 41 59 43 40 58]; %input Amplitudes of the frequencies 10 10 of them
forigin=[25 31.5 40 50 63 80 100 125 160 200]; % input frequencies in Hz of the matrix
S=zeros(1,length(t)); % row matrix initially populated with zeros 1 x 4000 secondary path
V=zeros(1,L); % row matrix of zeros from 1 to 4000primary path from 1 to 4000
for k=1:length(A) %
S = S+10^(A(k)/20)*sin(2*pi*forigin(k)*t); % secondary path calculated via for loop output sine wave?
V=V+sqrt(10^(A(k)/20))*sin(2*pi*forigin(k)*t);% primary path calculated via for loop output sine wave
end
I think the input is (a)
an the output is S and V

サインインしてコメントする。

採用された回答

Anish Navalgund
Anish Navalgund 2018 年 3 月 27 日
Hi! Matlab coder only converts function files to .c I suggest you to remove all your input functions like scanf() and build your code to act as a function where you have your input and output arguments.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by