how i can resolve the Error in sym/subsref (line 870) R_tilde = builtin('subsref',L_tilde,Idx);
10 views (last 30 days)
Show older comments
Husam Aneed
on 11 Oct 2020
Answered: Walter Roberson
on 11 Oct 2020
clc, clear all, close all
syms x %define the vairable of(x)
f=-1.8*x^4+6.03*x^3+57.03*x^2-171.41*x+30.30;
figure(1)
fplot(f);
xL = xlim;
yL = ylim;
line(xL, [0 0],'color','k','linewidth',2) %x-axis
title('plot of Polynomial function');
xlabel('X-axis');
ylabel('Y-axis');
hold on
%Find roots by using built in symbolic command
disp('Matlab built in Symbolic command (roots function)')
d=[-1.8,6.03,57.03,-171.41,30.30] %vector of coefficients
sol1=roots(d) %solve by roots function
plot(sol1,'ko') %draw solution
%Define regula falsi method as function
[xr,ir]=regulafalsi(f,3,7,1e-5,100);
function [c,i] =regulafalsi(f,a,b,delta,N)
% Regula falsi method
c=(a*f(b)-b*f(a))/(f(b)-f(a)); % 1st iteration
i=1; % number of iteration
% Stopping Criteria:
% error is smaller then the given tolerance, or the maximum iteration number is reached
while abs (f(c)) > delta && i <= N
if f(c)*f(a) < 0
b = c;
else
a = c;
end;
i = i + 1;
c = (a*f(b) - b*f(a))/(f(b) - f(a));
end;
end
0 Comments
Accepted Answer
Walter Roberson
on 11 Oct 2020
f=-1.8*x^4+6.03*x^3+57.03*x^2-171.41*x+30.30;
That is a scalar expression, not a function. f(a) would be a request to index it.
Instead of assigning to f, assign to f(x) to make it into a function.
0 Comments
More Answers (0)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!