Answered
How to find unique elements from every row within matrix??
y0 = sort(y,2); out = y(sum([ones(size(y,1),1),diff(y0,[],2)~=0],2) >= 9,:);

10 years ago | 1

| accepted

Answered
Integral of equation with vectors
h = 10; H = 4; a = [0 -0.7 -1.4 -1.8 -2.0 -1.9 -1.5 -0.9 -0.2 0.5 1.1 1.6 1.9 1.9 1.6 1.1 0.4]; u = [2.6 2.4 1.9 1.1...

10 years ago | 0

| accepted

Answered
How can I extract part of matrix on given dimension while this dimension is a variable?
function newMatrix = extractMatrix(matrix,dim,index) id = repmat({':'},1,ndims(matrix)); id{dim} = index; newMatrix =...

10 years ago | 0

| accepted

Answered
How to eliminate some coordinates values?
points = [2,4; 4,6; 6,20; 20,26; 15,6]; out = points(points(:,1) < 15,:);

10 years ago | 0

Answered
How to search row and delete row?
x= [15 30 45 60 -45 -30 0 90 15 30 45 60 -45 -30 0 90 15 45 60 -45 -30 0]; a = unique(x); b = a(a ~= x(end)); value = one...

10 years ago | 1

| accepted

Answered
Code for Jacobi's method using only one for loop
Hi Greta! Please use function <http://www.mathworks.com/help/matlab/ref/eye.html?searchHighlight=eye |eye|> and <http://www.math...

10 years ago | 0

Answered
find the closest element in each row of an array to each element of a vector?
a = [1 2 3]; b = [2 1 3; 5 2 3; 4 5 1]; [~,err_ind] = min(abs(bsxfun(@minus,reshape(a,1,1,[]),b)),...

10 years ago | 1

| accepted

Answered
Change values in an array based on existing values?
Maybe so crtimestamp_comp = timestamp_comp; t = abs(timestamp_comp(:,2)-timestamp_meta(:,2)) > 1e-5; crtimestamp_comp...

10 years ago | 0

Answered
How to split a matrix?
n = xlsread('try1.xlsx',1,'A2:D6'); [a1,~,c1] = unique(n(:,1)); c3 = (n(:,3)-240)/5+1; c4 = n(:,end)/5; n2 = n(:,2...

10 years ago | 0

| accepted

Answered
how to use find command to find data?
temp = [ 31.223 31.789 32.569]; elong = .5:.1:.7; inp = 31; [~,k] = min(abs(temp - inp)); out = elong(k);

10 years ago | 0

| accepted

Answered
find inverse matrix using naive gaussian elimination
[m,n] = size(M); A = [M, eye([m, n])]; for k = 1:m A(k,k:end) = A(k,k:end)/A(k,k); A([1:k-1,k+1:end],k:end...

10 years ago | 2

Answered
how to remove certain elements in 2D array?
use <http://se.mathworks.com/help/matlab/ref/setdiff.html |setdiff|> F = setdiff (c, d, 'rows')

10 years ago | 0

| accepted

Answered
Anonymous function/ Loop
anon = @(y,w) y*3-w*0.2; w = linspace(0,1,500); answer = arrayfun(@(y)fzero(@(x)anon(x,y),1),w); or anon = @(y,w...

10 years ago | 0

| accepted

Answered
Finding the indices of a reoccurring element in an array without using find
without |find|: a = (P(:) ~= 0).*(1:numel(P))'; out = a(a~=0);

10 years ago | 0

Answered
Converting 4D matrix to 2D with multiple for-loop
X = randi(100,10,100,10,100); A = randi(20,10,100); [k,l,m,n] = size(X); z = bsxfun(@times,X,A); out = reshape(s...

10 years ago | 3

| accepted

Answered
How to vectorize this function
median_bg_RedValues = median(bg_RedValues, 3); median_bg_GreenValues = median(bg_GreenValues,3); median_bg_BlueValues...

10 years ago | 0

| accepted

Answered
interpolation between two curves
Please use <http://se.mathworks.com/help/matlab/ref/griddedinterpolant-class.html |griddedInterpolant|>. Let A your data: ...

10 years ago | 0

Answered
Find repeated row from col1,check for different values in the related rows and move it to new columns
s = {[1] [ 1] 'as' 'vps' 'O363' 'hpv' [2] [ 7] 'ps' 'kp' 'O321' 'pp' [2] [ 7]...

10 years ago | 1

| accepted

Answered
Please tell me how i can find first three minimum elements in each column of a matrix?
A - your matrix. X = sort(A); out = X(1:3,:); or z = sort(A); x = diff(z)~=0; y = [cumsum(x).*x;zeros(...

10 years ago | 0

Answered
How can I eliminate a row and then make it appears again?
Let A - your array and b - value of your rank. for ii = 1:size(A,1)-1 rnk = rank(A([1:ii-1,ii+2:end],:)); if rn...

10 years ago | 1

Answered
How to solve equation with n data and select the maximum value of each answer?
n = numel(A); out = zeros(n,1); for jj = 1:n out(jj) = max(roots([1 -200 A(jj)])); end

10 years ago | 0

Answered
Cobine two cell arrays with Nested Cellfun
[b,a] = ndgrid(B,A); out = strcat(a,{'x'},b);

10 years ago | 0

Answered
How to randomly select information from an existing matrix
out = A(randperm(20000,150),:); % One way

10 years ago | 1

| accepted

Answered
I want to store the value of matrix in each iteration and add it to the stored matrix in the next iteration. At the end I would get the sum of all matrices in the loop.
Q = [ 171.1 3.622 0; 3.622 12.07 0 ; 0 0 4.5]; s0 = input('Total number of Layers:'); A = zeros(3,3,s0); for n=1:s0 ...

10 years ago | 0

Answered
How to sum up numbers from .txt file
f = fopen('name_of_your_txt_file.txt'); c = textscan(f,'%d %d %d %d %d %f','delimiter',',','CollectOutput' ,1); fclose(f...

10 years ago | 0

| accepted

Answered
Sum each element in a matrix with the previous elements on the same diagonal
B = fliplr(spdiags(cumsum(spdiags(A)))); B = B(:,all(B));

10 years ago | 3

Answered
compare and combine matrices
C = A; t = A~=B; C(t) = 10*(A(t) - B(t));

10 years ago | 0

Answered
how to assign 1 to negative value and 0 to positive values in dataset
n = xlsread('name_your_xlsx_file.xlsx'); out = n < 0;

10 years ago | 1

Load more