Error with parentheses when doing semilogy

조회 수: 2 (최근 30일)
Xavier
Xavier 2022년 11월 4일
답변: Cris LaPierre 2022년 11월 4일
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");

답변 (1개)

Cris LaPierre
Cris LaPierre 2022년 11월 4일
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?

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by