Error with parentheses when doing semilogy

2 visualizaciones (últimos 30 días)
Xavier
Xavier el 4 de Nov. de 2022
Respondida: Cris LaPierre el 4 de Nov. de 2022
I have an error when calling some functions that says that I don't have all of my parentheses and because of this, my code have invalid matlab syntax. I don't know if someone will be able to help me but it would be very appreciated! Thank you !
clear all;
close all;
clc;
f = @(x, u) (-u.^3*x.^4)+(2*u.^3*x.^3)-(u.^2)*(u+1)*(x.^2)+(u.^2*x);
x0 = 0;
Nmax = 100;
Ea = 10e-10;
[r] = pointsFixes(f, x0, Nmax, Ea);
nn = length(r);
err = abs(r(1:nn-1)-r(2:nn));
figure(1);
semilogy(0;nn-2, err);
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
title("Erreur selon le nombre d'itération");
xlabel("n");
ylabel("E_n");
figure(2);
plot(0:nn-3,err(2:nn-1)./err(1:nn-2).^1);
title("Pts fixe")
xlabel("n");
ylabel("E_{n+1}/E_n");

Respuestas (1)

Cris LaPierre
Cris LaPierre el 4 de Nov. de 2022
You have a syntax error in your inputs to semilogy. Did you mean to use a colon instead of a semicolon?
semilogy(0:nn-2, err);
% ^ colon?

Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by