MATLAB: Find the Argmin of a vector #argmin-vector Help: Let x be a vector and B_1…B_p p matrices, I look for the index j* of the matrix such that ||B_j*||=min ||B_i x||, (||.||=norm) How do I write this with matlab? Best Answer You should have avoided naming the variables that way, and should have used (for example) a cell array.Indeed. Here's an example of how to do it when that is the case.Bcell={rand(5), rand(5), rand(5), rand(5)}; %B1,...,Bp p=4[~, jstar] = min(cellfun(@(B) norm(B*x),Bcell)) %EDITED Related SolutionsMATLAB: Want to use a ‘for’ loop to swich between variables, like varname_1+n https://www.mathworks.com/help/matlab/matlab_prog/string-evaluation.htmlhttps://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval MATLAB: Replace elements in binary matrix % B original binary matrix% B_ new binary matrix B_ = ~B; Related QuestionConvert array in matrix
Best Answer