Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Function outputs the top row of a matrix, need it to output whole matrix

1 visualización (últimos 30 días)
Joshua Smith
Joshua Smith el 18 de Nov. de 2014
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
The function that is outputting incorrectly is the myBisection function. mySpringScaleFunction is required for it to function.
I want the function to output a whole matrix [gather], but it only outputs the top row of the matrix.

Respuestas (2)

Andrew Reibold
Andrew Reibold el 18 de Nov. de 2014
Editada: Andrew Reibold el 18 de Nov. de 2014
You have a counter here, but its not actually in a loop. I'm guessing thats a mistake. Count only ever equals 1 during assignment, so that means you are only populating the first row.
gathered(count,:) = count;
gathered(count,2) = xl;
gathered(count,3) = xu;
gathered(count,4) = xm;
gathered(count,5) = errorz;
gather = gathered;
counters = count +1;
Also should the first line be (count,1) intead of (count,:)??
EDIT: OR - If count is supposed to be passed out, then back in, you aren't passing out the NEW value of count out anywhere. Every time you recall the function count is whatever is in the input. The +1 isn't doing anything as written.

Joshua Smith
Joshua Smith el 19 de Nov. de 2014
i am doing this for an assignment and the function needs to be recursive, the purpose of the count is to have a sort of pseudo-loop. So the first time the function runs, it populates the first row because count = 1. Then count is ticked up by one and carried over into the next iteration of the function, which then populates the second row because now count = 2, and so on and so on until the errorz is less then a certain value.
about (count,:) that is something that I'll have to fix. Its a holdover from something I had originally tried to do.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by