How to Save multiple results into one array
古いコメントを表示
This seems simple, but I can't wrap my head around it
I am trying to save 2 variables that are output from the mink, where k=2, function into a single array
the results should be consecutive and be in a horizontal array, such that - for the first iteration the output was 4 and 6 and the second iteration the outputs are 8 and 9
so the array should be xval = [4,6,7,8..]
Below is the code I was working with however it did not work, any help is appreciated
xvalue=zeros(2*length(x),1);
for i=1:length(x)
xvalue(i)=mink(abs(Lx-x(i)),2); %
end
採用された回答
その他の回答 (1 件)
madhan ravi
2020 年 6 月 11 日
編集済み: madhan ravi
2020 年 6 月 11 日
xvalue = cell(numel(x),1);
for ii = 1:numel(x)
xvalue(ii) = mink(abs(Lx-x(ii)),2);
end
celldisp(xvalue)
cat(2,xvalue{:})
2 件のコメント
Hans123
2020 年 6 月 11 日
madhan ravi
2020 年 6 月 11 日
編集済み: madhan ravi
2020 年 6 月 11 日
xvalue{ii} % had to use {}
カテゴリ
ヘルプ センター および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!