MATLAB: A(a(a>3)<10) = OK ; a(a>3 && a<10) = wrong!, the correct way a=[1 2 3 4 11 33]; I want to get the number in a from 4-9; a(a(a>3)<10) is right; a(a>3 && a<10) is wrong — is there other correct way to make this ? Best Answer If you want to get only values between 3 and 10 (excluding the endpoints), the correct way would be:a(a>3 & a<10)(Not exactly sure what you meant by 'OK' but a(a(a>3)<10) definitely gives some unexpected results.) Related SolutionsMATLAB: Matlab I suspect you want bsxfun() . Trybsxfun(@times, a.', b) MATLAB: A(I) = B error. That’s actually fairly straightforward. You’re assigning a (3x1) vector vector of zeros to a scaler Xhat(i). That won’t work. Either:Xhat(i) = 0; % Scalar Assignmentor:Xhat(i,:) = zeroes(3,1); % Vector AssignmentYou later refer to a subscripted ‘Xhat’. so the second version is likely what you want. Related QuestionHelp with conidtional loopsIs b = a – a(1,:) not equal to a = a – a(1,:) where a is a column vector.How to format fprintf with 2 decimalsError a>b = true when a=b
Best Answer