What is the syntax error in this?

% This program calculates the amount of pasta to cook, given the number of people eating.
Author: Ettore Boyardee
numPeople = 2 // numPeople: Number of people that will be eating
totalOuncesPasta = numPeople * 3; % Calculate and print total ounces of pasta
Typical: 3 ounces per person %

3 comentarios

Aqila
Aqila el 13 de Ag. de 2023
Editada: Torsten el 13 de Ag. de 2023
the symtax 5p^3 give an error in matlab please select the option that is correct for this error
1). 5*.p^3
2). 5*p^3
3). 5p.^3
4). 5multiply p^3
Walter Roberson
Walter Roberson el 13 de Ag. de 2023
There are circumstances under which none of those answers are correct.

Iniciar sesión para comentar.

 Respuesta aceptada

James Tursa
James Tursa el 15 de Sept. de 2017
Editada: James Tursa el 15 de Sept. de 2017
Each comment section on a line needs to start with the % character.
The C/C++ style of commenting with // does not work with MATLAB. Use the % character.
E.g.,
% This program calculates the amount of pasta to cook, given the number of people eating.
% Author: Ettore Boyardee
numPeople = 2; % numPeople: Number of people that will be eating
totalOuncesPasta = numPeople * 3; % Calculate and print total ounces of pasta
% Typical: 3 ounces per person %

1 comentario

Walter Roberson
Walter Roberson el 15 de Sept. de 2017
Octave permits // comments. If you are using Octave then this is not the proper support resource: the behaviour of Octave is not always the same as MATLAB.

Iniciar sesión para comentar.

Más respuestas (1)

Jilesh Dilipbhai
Jilesh Dilipbhai el 26 de En. de 2023

0 votos

% This program calculates the amount of pasta to cook, given the number of people eating.
% Author: Ettore Boyardee
numPeople = 2; % numPeople: Number of people that will be eating
totalOuncesPasta = numPeople * 3; % Calculate and print total ounces of pasta
% Typical: 3 ounces per person %

Categorías

Etiquetas

Preguntada:

el 15 de Sept. de 2017

Comentada:

el 13 de Ag. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by