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 件のコメント

darova
darova 2019 年 10 月 8 日
Can you please describe the process? Can you be more precise?
Laura Echeverri Zea
Laura Echeverri Zea 2019 年 10 月 8 日
編集済み: Image Analyst 2019 年 10 月 8 日
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 2019 年 10 月 8 日
So? What's wrong with that?
darova
darova 2019 年 10 月 8 日
Exactly. Im curious
Laura Echeverri Zea
Laura Echeverri Zea 2019 年 10 月 8 日
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

サインインしてコメントする。

 採用された回答

Fabio Freschi
Fabio Freschi 2019 年 10 月 8 日

0 投票

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 件のコメント

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

サインインしてコメントする。

その他の回答 (1 件)

Laura Echeverri Zea
Laura Echeverri Zea 2019 年 10 月 8 日

0 投票

thank you :)

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by