Hi everyone. I'm trying to make code in which every time I run the code I have different values of X, and I what to save them in a matrix that changes size.
med = 8 (this value changes)
X = 2 (this value changes)
VecVal = zeros(1,med)

5 comentarios

darova
darova el 8 de Oct. de 2019
Can you please describe the process? Can you be more precise?
Laura Echeverri Zea
Laura Echeverri Zea el 8 de Oct. de 2019
Editada: Image Analyst el 8 de Oct. de 2019
i have to make measurements, so it will give everytime I'm going to have a different value of X, and i have to store those values each time so i can process them later on, but i don't know how many measurement i'm going to make, so i don't have the size of the matrix, so i created VecVal=zeros(1,med), where med is the number of measurements im making, and i want to start filling the matrix with the values of each measurement.
Image Analyst
Image Analyst el 8 de Oct. de 2019
So? What's wrong with that?
darova
darova el 8 de Oct. de 2019
Exactly. Im curious
Laura Echeverri Zea
Laura Echeverri Zea el 8 de Oct. de 2019
i'm sorry, im terrible expresing myself in eanglish...well, i don't know how to fill the matrix, because every time i run the code the matrix does only saves the new value and not the last ones, i dont know how to add the new mesurement values to the matrix with out deliting the ones from the other mesurements

Iniciar sesión para comentar.

 Respuesta aceptada

Fabio Freschi
Fabio Freschi el 8 de Oct. de 2019

0 votos

If I understand correctly
% number of measurements
med = 8;
% preallocation
VecVal = zeros(1,med);
% the measurement
X = 2;
% put it in a specified position, i.e. as first element
VecVal(1) = X;

2 comentarios

Laura Echeverri Zea
Laura Echeverri Zea el 8 de Oct. de 2019
thank you... and do you know how can i add another value of x to the matrix?
Fabio Freschi
Fabio Freschi el 8 de Oct. de 2019
VecVal(2) = Y;
VecVal(3) = Z;
Or you can do this in a loop
for i = 1:5
X = myNiceEvaluation;
VecVal(i) = X;
end

Iniciar sesión para comentar.

Más respuestas (1)

Categorías

Community Treasure Hunt

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

Start Hunting!

Translated by