How can I convert Matlab code to c#?

Need some help with matlab?

  • Hi, How would I go about writing a function in matlab that outputs an array of amplitudes for given times to produce a combined sine wave, when given arrays of freq, amp, phase and time. I have written some code that outputs the correct result: Fs = 8192; n=input('Enter the number of simple waves you would like to use: '); time = linspace(0,1,8192); for i=1:n freq = input(['Enter frequency ' num2str(i) ': ']); amp = input(['Enter amplitude ' num2str(i) ': ']); phase = input(['Enter phase ' num2str(i) ': ']); x(i,:) = amp .* sin(2 .* pi .* freq .* time + phase); t = sum(x); however i need to convert this into a function? Any ideas would be appreciated. Thanks in advance

  • Answer:

    A function is an m-file. It's defined in the first line of the code: function [out1, out2, ...] = your_function(in1, in2, ...) out1, out2... are the output variables in1, in2... are the input variables. I suggest you visit the site below. It gives you several detailed examples... .

jjasso5 at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

A function is an m-file. It's defined in the first line of the code: function [out1, out2, ...] = your_function(in1, in2, ...) out1, out2... are the output variables in1, in2... are the input variables. I suggest you visit the site below. It gives you several detailed examples... .

jjasso5

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.