how i can resolve the Error in sym/subsref (line 870) R_tilde = builtin('s​ubsref',L_​tilde,Idx)​;

2 ビュー (過去 30 日間)
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

採用された回答

Walter Roberson
Walter Roberson 2020 年 10 月 11 日
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 件)

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by