Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Simple Code wont run!
Replies: 4   Last Post: Nov 1, 2012 2:47 PM

 Messages: [ Previous | Next ]
 James Posts: 4 Registered: 11/1/12
Re: Simple Code wont run!
Posted: Nov 1, 2012 2:10 PM

Ok so now I have:

function [cosine] = james(x)
[cosine]=euler(x);
function [cosine]= euler(x)
cosine = exp.^((1i)*x)-1i*sin(x);
end

end

Matlab says that to compute

[cosine]=euler(0:pi/4:2*pi)

i need to have exp as exp.^ and not exp^ but this still causes an error of :

Error using ^
Inputs must be a scalar and a square
matrix.
To compute elementwise POWER, use POWER

Error in euler (line 3)
cosine =e^(1i*x)-1i*sin(x);

What exactly am doing wrong? I put the exp.^ just as matlab said but Matlab still says there is the same error!

Date Subject Author
11/1/12 James
11/1/12 Steven Lord
11/1/12 James
11/1/12 Curious
11/1/12 dpb