Borrar filtros
Borrar filtros

Store Answers into Matrix

2 visualizaciones (últimos 30 días)
Eric Daiber
Eric Daiber el 27 de Sept. de 2016
Respondida: Image Analyst el 27 de Sept. de 2016
What does the x = [] and the x = [x;T, y] mean? I know what it does, I am wondering if someone could explain the syntax?
F = @(m,y) 5*m+7*y
x=[];
if true
for y=2:0.1:10
T = fzero(@(m) F(m,y), 5)
x=[x; T,y)];
end
end
Thanks, Eric

Respuestas (1)

Image Analyst
Image Analyst el 27 de Sept. de 2016
x=[] initializes x to null. You need to do this because x must exist when you append to it with the x=[x; T,y)]; statement. The right parenthesis in that line is a mistake. If you don't have x already, then what would it append T and y to? That's why you had to initialize x to an empty matrix.

Categorías

Más información sobre Matrix Indexing 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