nth root in matlab

To find the nth root of a number in MATLAB, you can use the power function with an exponent of 1/n. Here is an example:

main.m
n = 3; % the value of n
x = 125; % the number you want to find the nth root of
result = power(x, 1/n); % calculate the nth root using the power function
disp(result); % print the result
186 chars
5 lines

In this example, we are finding the third root (n=3) of 125. The power function with an exponent of 1/n will calculate this for us, and we store the result in the variable 'result'. We then print the result to the console using 'disp'. You can change the values of 'n' and 'x' to find different nth roots of different numbers.

gistlibby LogSnag