Answered
How do I find the row number where the first zero occurs and last zero occurs in an excel spreasheet?
a = [ 5 6 7 4 6 0 0 0 0 5 6 4 3 5 6 7 0 0 0 0 0 4 5 6 0 0 0 0 6 6 4 4 0 0 0 0]; t = a == 0; ii = strfind([0,t],[0, 1...

11 years ago | 1

Answered
How can i find,most and less reapted number in array or matrix?
X=[1 3 3 3 3; 3 7 4 4 4; 4 7 5 5 5; 5 9 8 8 8 ]; c = unique(X(:)); z = histc(X(:),c); out = sortrows([c,z],2);

11 years ago | 0

| accepted

Answered
How to find the number of point inside the graph?
x = [0,7, 18, 37,47,54,57.5,59,61.5,69,87,95,99,103,110]'/110; % Let this y = [0, 15,43,53,42,20,7,0, 37, 61,56, 40.5, 24, ...

11 years ago | 1

Answered
combining cell array problem
out1 = [cell1,cell2,cell3,cell4,cell5]; cell0 = cellstr(cat(1,out1{:}))'

11 years ago | 0

Answered
Calculate a mean if one statement is true for a previous row
out = mean(cellm(6,strfind(cellm(5,:),[0, 1])+1));

11 years ago | 0

| accepted

Answered
i have string matrix which contains Row and Column. so how i can change one Row
reshape(Bits_com',1,[])

11 years ago | 1

| accepted

Answered
randomly select a number from a matrix
n = size(Matrix); out = Matrix(sub2ind(n,(1:n(1))',randi(n(2),n(1),1)));

11 years ago | 0

Answered
Base convertion without dec2base and base2dec
function bs = dec2base_mtx(d,base,l) %input: d - array, 'base' - base, l -> 'length' numbers in row ll = ceil(log(max(d(...

11 years ago | 1

Answered
combination of first row of G1 and first row of G2 until row13 of G1 and row13 of G2.
G1 = ['000001001' '010111100' '111111001' '001111001' '000000010' '001011011' '100110101' '010101000' ...

11 years ago | 0

| accepted

Answered
expanding arrays to take all permutations for add/subtract operations
distance = 1./squeeze(sum(bsxfun(@minus,a,permute(b,[3, 2, 1])).^2,2));

11 years ago | 0

Answered
Using reshape function i get wrong ans....
b=[0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1]; SS=reshape(b,8,[]); SS([end,end-1],:) = SS([end...

11 years ago | 0

| accepted

Answered
double integral using trapz
Try use idea by Walter (+1): x = 0:.1:1; f = @(x)sqrt(1 - x.^2); [yy,xx] = ndgrid(x); out = trapz(x,trapz(yy,f...

11 years ago | 0

Answered
converting cell string into number
wm={'000' '402' '101' '000' '000' '0124' '011'}; z = cellfun(@(x){x(1),x(2),x(3:end)},wm,'un',0); y = ...

11 years ago | 0

Answered
Comparing vectors and determining unique values?
c = C{1} for ii = 2:numel(C) c = setdiff(c,C{ii}); end

11 years ago | 0

Answered
how to delete the duplicated rows (in a specific way)?
a = [text{:,1}]; m = numel(a); [~,b1,c1] = unique(a,'first'); n = ones(m,1); n(b1(2:end)) = 1-diff(b1); i1 = ac...

11 years ago | 1

| accepted

Answered
find matched data (place of equal values) ?
a1 = cat(1,querymdr{:}); a2 = cat(1,alldata{:,1}); ii = ismember(a2,a1); record = [alldata{ii,6}];

11 years ago | 1

| accepted

Solved


Find the sum of all the numbers of the input vector
Find the sum of all the numbers of the input vector x. So if input x is x = [1 2 3 5] then the output y should be 11.

11 years ago

Answered
How to find zeros of a polynomial and choose values within a specific range?
v = arrayfun(@(x)reshape(roots([a,b,c,d-x]),1,1,[]),P,'un',0); out = cell2mat(v);

11 years ago | 0

Answered
Counting number of 1's in different bins
A = [100 150 190 200 250 300 350 370 390 400 400]; B = [ 0 1 0 0 1 1 1 0 1 0 1]; [~,i...

11 years ago | 0

Answered
How can I find the yearly average with repeating years?
years = sort(randi([2013,2015],10,1)); water_level = randi([20 50],10,1); [a,~,c] = unique(years); out = [a,accum...

11 years ago | 1

Answered
How do I delete repetitions of rows in a matrix?
out = unique(A,'rows','stable'); old version of MATLAB: [~,b] = unique(A,'rows','first'); out = A(sort(b),:);

11 years ago | 1

Answered
How can I create a sub-matrix if the number of rows change according to main-matrix?
A=[2.36; 2.36; 2.36; 1.93; 1.93; 1.41; 1.41; 1.41; 0.39]; [a,b,c] = unique(A,'first'); [ignored,ii] = sort(b); b1...

11 years ago | 1

Answered
Interpolation between three sets of data
Let your data S (Speed) V (voltages): V = [9, 13.5, 16]; S = randi(20,10,3); Solution: n = 1:size(S,1); [...

11 years ago | 1

| accepted

Answered
How to evaluate mean for column
[~,~,c] = unique(B); out = accumarray(c(:),A(:),[],@mean);

11 years ago | 1

Answered
How do i create two multi-dimensional arrays:  a 10 x 10 x 10 numerical array (3-D) anda 5 x 5 x 5 x 5 numerical array (4-D) where each value in each array corresponds to the multiplication of indices?
variant 3D: n = [10 10 10]; A = bsxfun(@times,(1:n(1))'*(1:n(2)),reshape(1:n(3),1,1,[])); 4D: n = [5 5 5 5]; ...

11 years ago | 0

Answered
1 and 0 matrix
n = 5; % size your matrix k = 10; % your percent out = zeros(n); out(randperm(n^2,ceil(n^2*k/100))) = 1;

11 years ago | 1

| accepted

Answered
How do I create discrete intervals, sum relevant data and produce a histogram?
Y= [1, 1.1, 1.8, 0.7, 1.2, 1.7, 0.1]; X= [15, 21, 12, 24, 5, 34, 38 ]; [~,ii] = histc(X,[0:10:30,inf]); out = acc...

11 years ago | 1

| accepted

Answered
find first value and repalce values following it
A = [1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 0 0 1]; cumprod(A)

11 years ago | 1

| accepted

Answered
-1 and 1 matrix
-(-1).^(1:5)'*ones(1,5);

11 years ago | 2

Load more