Keep getting error with sample code
Afficher commentaires plus anciens
So the commented up code was the one that was provided to essentially plot my part, yet I keep getting these errors: Undefined function 'number_of_solutions' for input arguments of type'double'.
Error in Lab4 (line 68)
n = number_of_solutions(A(m), b(m));
Not sure why I'm getting these errors, are there any toolboxes or something that I'm missing. Thanks.
clear, clc, close all
syms m f
A = @(m) [m -1; (3*m-m^3) (1-3*m^2)];
b = @(m) 2*(1-m) * [1; (m^2+4*m +1)];
det(A(m));
f = matlabFunction(det(A(m)));
eqn = f(m) == 0;
solve(eqn)error wit
dx = 0.05; dy = 0.25;
for m = -2.6 : 0.2 : 2.6
n = number_of_solutions(A(m), b(m));
if f(m) == 0
zero_marker = plot(m, 0, 'bo', 'MarkerSize', 16, 'MarkerFaceColor', 'white');
else
plot(m, f(m), 'bh', 'MarkerSize', 10, 'MarkerFaceColor', 'green')
end
the_text = text(m+dx, f(m) + dy, num2str(n), 'FontSize', 24) ;
the_text.set('FontWeight', 'bold', 'HorizontalAlignment', 'center', 'VerticalAlignment', 'bottom');
% Auto Color Code the Zero Markers and the Text
if n==0 % inconsistent! No solutions
the_text.set('Color', 'red')
% Add code to set the MarkerFaceColor for zero_marker to red.
set(zero_marker, {'MarkerFaceColor'}, get(zero_marker, 'red'));
elseif n==inf % there are free variables
the_text.set('string', '\infty')
% Add code to set the MarkerFaceColor for zero_marker to yellow.
set(zero_marker, {'MarkerFaceColor'}, get(zero_marker, 'Yellow'));
else
the_text.set('Color', 'green') % unique solution!
end
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Numerical Integration and Differentiation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!