number to a power in matlab

To raise a number to a power in MATLAB, you can use the ^ operator. Here's an example:

main.m
x = 2;
y = x^3; % raises x to the power of 3
disp(y); % outputs 8
66 chars
4 lines

Alternatively, you can use the power function:

main.m
x = 2;
y = power(x, 3); % raises x to the power of 3
disp(y); % outputs 8
74 chars
4 lines

Both methods will give you the same result.

gistlibby LogSnag