I'm not sure why this isn't executing properly. The vector analysis is not correct
Info
This question is closed. Reopen it to edit or answer.
Show older comments
%%Evaluating the Rational Funciton
% First I let the user input the first value of x and store the variable
% into "x"
x1 = input('Enter the first value of x. ');
% Then I defined the formula they are suppposed to carry out
% The numerator is defined as "a"
a = (x1.^4)-(3.*x1.^2)+2.4;
% The denominator is deifned as "b"
b = (.0002.*x1.^3)+x1-1.2;
% The full formula is defined as "a/b"
y1 = a./b;
fprintf('The rational function with x1 %6.1f is %6.1f\n',x1,y1)
% Then I let the user input the second value of x and store the variable
% into "x"
x2 = input('Enter the second value of x. ')
% Then I defined the formula they are suppposed to carry out
% The numerator is defined as "c"
c = ((x2.^4)-(3.*x2.^2)+2.4);
% The denominator is deifned as "d"
d = ((.0002.*x2.^3)+x2-1.2);
% The full formula is defined as "c/d"
y2= c./d;
% Print to the screen the result along with complete description
fprintf('The rational function with x2 %6.1f is %6.1f\n',x2,y2)
Evaluate using x1=0.4 and x2=[0.3 0.39 0.3999 0.3999]
I am trying to help a friend of mine with a program, but I cannot figure out why this is not working. Any help would be appreciated
2 Comments
Walter Roberson
on 18 Jan 2013
What evidence is there that the output is not correct?
Roger Stafford
on 18 Jan 2013
Values of x out to four decimal places have been entered but there is only one decimal place displayed in the fprintf format "%6.1f". I think you need more.
Answers (0)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!