MATLAB: Replacing the values matrix I have a matrix of 100×62 ,the min and maximum values are ,0.2 and .9 respectively ,now i want all these values to be replaced by "DBLCL",PLEASE HELP Best Answer If DBLCL is a variable that has a number in it, you can do something like this:m = rand(11,10); % Sample data.% Find indexes matching the replacement criteria.indexes = m > 0.2 & m < 0.9;% Do the replacement.m(indexes) = 99 % Or whatever other number you want. Related SolutionsMATLAB: Replace p percent of largest values in matrix columns By "I want to replace p percent of largest values", I assume you mean replace the value of A that are greater than (1-p) * max_value_of_A. If not, you'll have to clarify what you mean.A = rand(8, 10) %for examplep = 0.1; %for examplemaxvalue = max(A(:));threshold = (1-p) * maxvalue;A(A >= threshold) = NaN MATLAB: Replace Nan with previous numbers t = ~isnan(data);a = data(t);out = a(cumsum(t));ADD on Aggelos's commentt = ~isnan(data);idx = cumsum(t);idx(~idx) = 1;a = data(t);out = a(idx); Related QuestionFprintf replace values from xlsread tableReplace columnReplace values with nansHow to replace roundnHow do you replace the entry of a matrix with a stringReplace buttons
Best Answer