Answered
Creating a matrix based on information in a vector and another matrix
For MARLAB >= R2016b out = ~o - p; out(o>0) = -out(o>0); MATLAB <= R2016a out = bsxfun(@minus,~o,p); out = ou...

9 years ago | 0

Answered
To put score value based on neighbor column position value in same row
fu ={{'Q7' 'Q12F' 'Q12G' 'Q12H' 'Q12I' 'Q12L' 'Q12M'}; {'Q12G' 'Q12H' ...

9 years ago | 1

| accepted

Answered
To combine different cells with empty columns together
fu ={{ 'Q7' 'Q12F' 'Q12G' 'Q12H' 'Q12I' 'Q12L' 'Q12M'}; {'Q12G' ...

9 years ago | 0

| accepted

Answered
Change specific matrix values to negatives
B.*sign(A) or (1-(A < 0)*2).*B or B(A < 0) = -B(A < 0);

9 years ago | 0

| accepted

Answered
find a row in a multidimensional cell array
find(all(ismember(temp(:,1:2),key(1:2)),2) & ismember([temp{:,3}]',key{3}))

9 years ago | 0

Answered
Check and eliminate rows based on conditions 2
[~,ii] = sort(A(:,3),'descend'); for MATLAB >= R2016b out = A(ii(all(tril(ii < ii')==0,2)),:); for MATLAB <= R2016a...

9 years ago | 0

| accepted

Answered
Centre of a matrix
A = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 5 6 7 1 2 0 0 0 0 2 0 0 0 3 8 0 0 0 0 4 0 0 0 7 6 0 0 0 0 4 ...

9 years ago | 0

| accepted

Answered
Binary Image: Count number of pixels that are 1.
May be so: I = imread('rice.png'); figure; imshow(I); bw = imbinarize(I); figure; imshow(bw); ctr= 0; for i ...

9 years ago | 0

| accepted

Answered
How can I delete specific columns from a matrix?
your_mtx = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

9 years ago | 0

Answered
apply arrayfun for a couple of values
x1=[1 2 10 11]; x2=[10 11 12 14]; [x,y] = ndgrid(x1,x2) C = arrayfun (@(t1,t2) myfunction(A,B,t1,t2),x,y,'Uniform...

9 years ago | 1

| accepted

Answered
i want to make the arrangement of 3rd column of matrix decendly and any element which inteerept i want to remove the whole row of this element
k = strfind((diff(A([1,1:end],3)) > 0)',[0,1]); v = zeros(size(A,1),numel(k)); v(sub2ind(size(v),k,1:numel(k))) = 1; ...

9 years ago | 0

Answered
User defined distance function
r = [0 3 4 5;7 6 3 -1;-1 1 -1 1;2 3 4 5]; for MATLAB >= R2016b dist = squareform(pdist(r,@(a,b)sum(abs(a - b)./(abs(a)...

9 years ago | 1

| accepted

Answered
I solve this equation and only get one answer zero. how can I find more answers for x ? For example some other answers are 3.9887 ; 7.1025 ; 10.2340; 13.3701 . Thanks
F = @(x)1-cos(x)*cosh(x)+2*x*(sin(x)*cosh(x)-cos(x)*sinh(x)); x = (0:100)*pi; for ii = numel(x)-1:-1:1 r(ii,1)...

9 years ago | 1

| accepted

Answered
Sorting Data in MAtrix1 referencing matrix2
n = numel(B); b0 = interp1((1:n)',B(:),linspace(1,n,numel(A))'); [~,i0] = sort(b0); a0 = sort(A); [~,i1] = sort(i0...

9 years ago | 1

Answered
Compare values in array1 with array2 and store a new value in a new array if match found
A = sortrows(Array2,1); out = A(discretize(Array1,[-inf;A(1:end-1,1)+diff(A(:,1))/2;inf]),2);

9 years ago | 0

Answered
Character Cell Array Comparison
[a,~,c] = unique(test); out = a(accumarray(c,1)>1 & ~strcmp(a,'[]'));

9 years ago | 0

| accepted

Answered
datestr problem with minutes
a = datetime('1/5/2017 12:10:00AM','I','dd/MM/yyyy hh:mm:ssa','F','yyyy-MM-dd HH:mm:ss')

9 years ago | 0

Answered
Array of structures containing arrays
s(1) = struct('field1', [1:3;4:6]); s(2) = struct('field1', [4:6;1:3]); z = cell2mat(struct2cell(s)) out = squeez...

9 years ago | 0

| accepted

Answered
finding mathematical function of set of points and draw it
x= [10.5 17.5 24.5 31.5]; Y =[5.11804923375421 3.92022009244337 2.14345898571206 1.24047882220866]; f = fit(x(:),Y(:...

9 years ago | 0

| accepted

Answered
how can slect randomly numbers from two array s
A=[3818.36,7632.40,11446.44,15260.48,19074.52]; B=[657.15,1089.15,1521.15,1953.15,2385.15]; C = [A;B]; out = C(s...

9 years ago | 0

Answered
How do I plot a circular arc with given two endpoints and radius?
p = [4 10;7 4]; % p - this is our points p1 & p2, p =[x1,x2;y1,y2]; r = 7; % r - radius % Finding the coord...

9 years ago | 3

Solved


true or false
if the matrix has a zero, return true. else, return false

9 years ago

Solved


Sum of odd numbers in a matrix
Find the sum of all the odd numbers in a matrix. Example x = [2 3 5 7 1 4 11] y = 27

9 years ago

Solved


Replace Negative(-) by 0 and positive by 1
In a given Matrix Replace all element having *Negative sign with 0* and *Positive elements with 1* .

9 years ago

Answered
If I start with a matrix of zeros, how can I easily create a circle of ones in that matrix?
Use function |bwdist| from |Image Processing Toolbox|: N = 1001; R = 400; M = zeros(N); ii = ceil(N/2); M(ii,ii...

9 years ago | 3

| accepted

Answered
How to find rank within group
[~,a] = cellfun(@sort,accumarray(group_id,y,[],@(x){x}),'un',0); rank = cell2mat(a); or within |for..end|: y=[1; 3;...

9 years ago | 1

| accepted

Answered
Circle in a matrix
M = zeros(1001); M(500,500) = 1; R = bwdist(M); T = R >= 300; imagesc(T)

9 years ago | 3

Answered
How can i compare two specific cells of two matrices?
[lo,idx] = ismember(path24(:,1:2),path12(:,1:2),'rows'); path_out = path24; path_out(lo,3) = path_out(lo,3) + path12(idx...

9 years ago | 1

Answered
How to use symbolic toolbox to solve a system of equations in terms of a variable (s)
syms s A=[2+4/s, -4/s, -2, 2/s/(s+2);-4/s, 4+4/s, -2, 0;-2, -2, 4+s, 0]

9 years ago | 1

| accepted

Answered
Create symbolic matrix from triplets with repeated indices
iRow = [1 2 1 2]; jCol = [1 1 1 2]; aElm = sym('a',[1 4]) k = accumarray([iRow(:),jCol(:)],(1:numel(iRow))',[],@(...

9 years ago | 0

| accepted

Load more