Answered
How to select non zero elements of matrix/array and return a 2d array of values and index positions
[r,c,v] = find(a); out = [v,r,c];

11 years ago | 0

| accepted

Answered
I want to calcualate this without for loop
try use variant with |Image Processing Toolbox| image1= imresize(o_image, [256, 256]); b_image = imfilter(image1...

11 years ago | 1

| accepted

Answered
How to get the starting and ending index of repeated numbers in an array?
A=[2 2 1 2 3 2 2 2 2 2 3 5 6 7 7 7 7 6 5]; ii = [0, diff(A(:)')==0,0]; i1 = strfind(ii,[0 1]); i2 = strfind(ii,[1 0])...

11 years ago | 0

Answered
different answers for implementing summation
J = sum(f1-a*exp(-(x1-mu).^2/sigma)).^2) for 2 variant: f1=[10 20 30 40 50] x1=[1 2 3 4 5] J1=0 J=@(f...

11 years ago | 0

Answered
Identify which row has a number which exceeds a number N
any([A > N, A == 0 , ~diff(sort(A,2),[],2)],2)

11 years ago | 0

Answered
how can I add zeros elements to a matrix?
a= [1 2 3; 1 2 3; 1 2 3] b = a b(5,5) = 0

11 years ago | 8

Answered
converting cell array to matrix
a = {'a' , 'b' , 'c' ,'d' , 'e'}; a = sprintf('%c,',[a{:}]); a = a(1:end-1);

11 years ago | 1

| accepted

Answered
converting a double array to a logical array conditionally
A = [2 1 6 7 3 5 4]; B = ismember(sort(A),A(1:3));

11 years ago | 0

| accepted

Answered
Sorting elements in a matrix via first column characterization
B = sortrows(A,1); or [~,ii] = sort(A(:,1)); B = A(ii,:);

11 years ago | 0

Answered
I want to normalize a vector in range -5 to +5. Is it possible?
As wrote Guillaume: variant 1: out = A - 5; % if A >= 0 & A<=10 variant 2: m = min(A(:)); out = (A(:)-m...

11 years ago | 0

Answered
How do I interpolate usng vectors? and they are large..
F = scatteredInterpolant([depth,lon],temperature); use l1 = linspace(min(depth),max(depth),1000); l2 = linspace...

11 years ago | 0

| accepted

Answered
Calling text file in matlab
ii = [1 2 1 3 1 1 2 3 1]; s = [0.3 0.4 0.6 0.1 0.5 0.7 0.2 0.11 0.9]; [x,y,z] = size(s); ij = ...

11 years ago | 1

| accepted

Answered
help for matrix manipulation with loop
n= 3; out = [zeros(n);eye(n)]; with loop out = zeros(2*n,n); for jj = 1:n out(jj+3,jj) = 1; en...

11 years ago | 0

Answered
repalacement of string with phone numbers
function out = funbyMuhammad(in_char) abc = ['()+-_',setdiff('A':'Z','QZ')]; d = ['#*','0':'9',' ']; if a...

11 years ago | 1

| accepted

Answered
Sum of cross diagonals of a non symmetric matrix
sum(spdiags(A(end:-1:1,:)))

11 years ago | 0

Answered
how to average the minutes data to hourly data if the data is missing for some minutes(samples) in between
n = xlsread('Book1.xlsx'); n(:,1) = n(:,1) + datenum('30.12.1899','dd.mm.yyyy'); [Y,M,D,H] = datevec (n(:,1)); [c0,~,...

11 years ago | 1

| accepted

Answered
How to shift just the outer loop in an array?
A = [1 2 3 4 5; 6 7 8 9 10; 11 12 13 14 15; 16 17 18 19 20], mover = 2 [m,n] = size(A); i0 = [(1:m)';(2:n)'*m;m*n - ...

11 years ago | 0

Answered
Concatenate Columns of Cells
d = { '01/04/2004' [ 0] [ 0] [ 0] [ 0] '01/04/2004' [ 0] [...

11 years ago | 0

Answered
How can I set specific Elements of a Matrix to zero without a for loop
o= ones(3,3); ii = [1 2 2]; [m,n] = size(o); o(sub2ind([m,n],(1:m)',ii(:)')) = 0; other way n = 3; ou...

11 years ago | 0

| accepted

Answered
Grouping elements in an array?
x = struct2cell(data); out = cellfun(@(y)nanmean(reshape([y,nan(1,mod(-numel(y,7))],7,... ...

11 years ago | 0

| accepted

Answered
How do you maintain value order when removing zeros from a matrix?
SP_Marker_C(~cellfun('ischar',SP_Marker_C)) = {[]}; or SP_Marker_C(cellfun(@(x)x == 0,SP_Marker_C)) = {[]};

11 years ago | 0

Answered
Replacing Matrix Cells with Date Values
d = {'01/04/2004' '02/04/2004' '03/04/2004'... '04/04/2004' '05/04/2004' '06/04/2004' '07/04/2004'}; ...

11 years ago | 1

Answered
how to make function that return struct vector whose elements are days of month
function out = May2015 [~,k] = weekday(datenum(2015, 5, (1:31)')); out = struct('month','May','date',num2cell((1:31)'),'...

11 years ago | 1

Answered
How to index on a loop for first occurrence?
a = [1 0 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 ...

11 years ago | 1

Answered
Make matrix from input size
sortrows(fullfact(size(mat)),1)

11 years ago | 1

Answered
Searching a cell array of percentile scores based on age and gender
S = table(arrayfun(@(x)sprintf('Y%02d',x),(1:5)','un',0),[19;22;21;nan;19],... [1;1;1;nan;1],{'','58.39','61.2...

11 years ago | 0

| accepted

Answered
How to make a function that calculate appoximate value of pi
function [pi_here,k1] = a_pi(delta) f = @(k)sqrt(12)* 1./( (2*k+1).*(-3).^k ) ; k1 = ceil(fzero(@(k)abs(f(k))...

11 years ago | 1

| accepted

Answered
How to symmetrize a matrix
[ny,nx]=size(M); if ny~=nx m = max(ny,nx); M(m,m)=0; end

11 years ago | 0

Load more