I am converting a program from c++ to matlab. I have written this code, but keep getting an error that reads "undefined function or variable x_old". How an I fix this?
This is my code so far:
num = input('Enter a positive number: ')acc = input('Enter convergence criterion: ')approx = input('Enter initial apporiximation: ')x = approx;while abs(x-x_old)>acc x_old = x; y = 1/num*x*x; x = x/8*(15-y*(10-3*y));enddisp(['Square root of' num2str(num) 'is' num2str(x)])
Best Answer