MATLAB: Hi everyone , i need help to do this , thank u MATLAB clear all clc A=10*randn(1,8); B=10*randn(1,8); EA=A+2 EB=B+2 E=min(EA,EB) % i need the value of A and B in a row vector that corrispond to the value of E thank u Best Answer The variable 'idx' tells you whether the minimum came from EA (idx=1) or EB (idx=2). Use that to pull out values from A and B as needed. [E, idx] = min([EA;EB]); %only works if EA and EB are same size% If you want one row vector of A and one for BA0 = A(idx==1); B0 = B(idx==2); % If you want one row vector that combines A and BAB = nan(1, length(E));AB(idx==1) = A(idx==1);AB(idx==2) = B(idx==2); Related SolutionsMATLAB: Can anyone help me to run this code , thank you for i=1:300 for j=1:100 A{i,j}=10*randn(2,8); B{i,j}=10*randn(2,8); MA{i,j}=mean(A{i,j},1); MB{i,j}=mean(B{i,j},1); [E{i,j}, idx{i,j}] = min([MA{i,j};MB{i,j}]); AB{i,j} = nan(2, length(E{i,j})); AB{i,j}(:,idx{i,j}==1) = A{i,j}(:,idx{i,j}==1); AB{i,j}(:,idx{i,j}==2) = B{i,j}(:,idx{i,j}==2); endend MATLAB: Graficar una seƱal discreta a partir de una matriz zp = find(x==2,1);X = (1:length(x))-zp;stairs(X, x) Related QuestionI have a piece of code and can anyone explain how it worksSolve symbol four equations for c1 c2 c3 c4How to generate a 2D grid plot the dataHow to change 3d array to 2 d arrayMultiply two series of vector in loopsWarning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.735910e-18.
Best Answer