Question: Output CodeGeneration Matlab to a file

Hello, 

I would like to write to a file the output of the command CodeGeneration[Matlab]. I couldn't find a way to write the output. 

What I am trying to do is to generate complex symbolic equations and expressions and write them as either a function or variables in matlab. 

As an example: 

exp := [sin(theta(1)), cos(theta(1))]; 

func := unapply(exp,[theta]); 

CodeGeneration:-Matlab(func)

If i can write the output of the above command in a matlab file, it will generate a matlab function file. 

I was using the command 'writeto' but this one basically outputs every line a command written to a file instead of the terminal, which is not what I want (it will output even the warnings, I know I can silent them!). 

can you please help.. thanks. 

Please Wait...