gistlib
To raise a number to a power in MATLAB, you can use the ^ operator. Here's an example:
^
main.mx = 2; y = x^3; % raises x to the power of 3 disp(y); % outputs 8 66 chars4 lines
x = 2; y = x^3; % raises x to the power of 3 disp(y); % outputs 8
Alternatively, you can use the power function:
power
main.mx = 2; y = power(x, 3); % raises x to the power of 3 disp(y); % outputs 8 74 chars4 lines
x = 2; y = power(x, 3); % raises x to the power of 3 disp(y); % outputs 8
Both methods will give you the same result.
gistlibby LogSnag