Answered
Multiplication in cell arrays
mul={[1,1,0.6,0.6,0.3];[1,1,0.6,0.6,0.3,0.3]}; A{1,1}={1,2,4;2,0,0;0,1,0;5,0,1;1,0,0}; A{2,1}={3,0,0,0;0,0,0,3;3,0,0,0;2...

9 years ago | 0

| accepted

Answered
loop in a loop
v_0=(3:0.1:20); m = numel(alpha); n = numel(v_0); v = zeros(m,n); for ii=1:m for jj=1:n t=(5/4...

9 years ago | 0

Answered
how can I use optimization tools to minimize x
x = A\b in your case: x = dicexp\dam2norm;

9 years ago | 0

| accepted

Answered
how can i creat matrix min{i,j} when i,j=1,...,n
*[EDIT]* ii = 1:10; jj = 1:10; out = min(ii(:),jj(:)'); % for MATLAB R2016b and later out = bsxfun(@mi...

9 years ago | 1

Answered
How do I find the value of one column based on the value of another?
Let A - your matrices: A = randi(1000,10,2,3); [~,ii] = max(A(:,2,2)); out = A(ii,1,2);

9 years ago | 0

Answered
Convert cell array to matrix
m = max(cellfun(@max,A)); n = numel(A); B = zeros(m,n); B(sub2ind([m,n],[A{:}],repelem(1:numel(A),cellfun(@numel,A)))...

9 years ago | 0

Answered
Add element to the matrix in one sentence
A=zeros(10,10); ii = [5,3,2,5,3,100,5]; var = 1:7; [ii,ib] = unique(ii); A(ii) = var(ib); or A([5,3,2,...

9 years ago | 0

| accepted

Answered
Remove non-empty and zeroed cells from cell array.
A = myArray'; [~,ii] = find(~cellfun(@isempty,A)); out = accumarray(ii,[A{:}]',[],@(x){x'})

9 years ago | 1

| accepted

Answered
How to change duplicate values, so that every value is unique
a = [10 20 20 30 20 30 40]'; [~,ii] = sort(a); [~,~,c] = unique(a); jj = cell2mat(accumarray(c,.1*ones(numel(a),1),[]...

9 years ago | 1

Answered
Reorder confusion matrix in vectorized way
circshift(A,[1 1])

9 years ago | 0

Answered
calculate the function in vector.
function [output] = AsPolyvalForJaeSung(input) output = bsxfun(@power,input(:),0:5)*[1.0000;1.0001;0.4991;0.1703;0.0349...

9 years ago | 0

| accepted

Answered
Multiply each column by a elements of cell array
result = matrix.'*cat(1,mul{:}); or result = [mul{:}]*matrix;

9 years ago | 1

Answered
How to place contents into a specif cell index?
AA = cat(4,A{:}); AA(:,:,3,:) = cat(3,B{:}); A = squeeze(num2cell(AA,1:3)); or with loop |for..end| for ii = 1:n...

9 years ago | 0

| accepted

Answered
็How to compare value in cell array
cellfun(@(x)x == 'A',status)

9 years ago | 0

| accepted

Answered
Maintain shape of logical index mask
Aout = A'; Aout = reshape(Aout(Aout ~= z(:)'),[],2)'; or Aout = A'; Aout = reshape(Aout(~ismember(Aout,z)),[...

9 years ago | 0

| accepted

Answered
Extract value in cell array based on
s = [str,str2]; strvector = string({'A','t'}); out = a(ismember([str,str2],string({'A','t'}),'rows'))

9 years ago | 0

| accepted

Answered
Re-indexing matrix which corresponds to mesh
Node_out = (1:numel(Node))'; [~,Triangles_out] = ismember(Triangles,Node); or [v,~,Node_out] = unique(Node,'stable'...

9 years ago | 2

Answered
Find common non-zero indexes
*[EDIT 2]* A=[4,0,5,5;0,2,4,0;3,0,0,0;0,1,0,3;3,0,1,0;2,0,0,2;0,0,3,0;2,3,4,0]; B=[7;8]; [C,~] = find(bsxfun(@ne,(1:s...

9 years ago | 0

| accepted

Answered
compare elements of cell array
f = @(x)cellfun(@(y)y(ismember(y,array{x})),array([1:x-1,x+1:end]),'un',0); out = arrayfun(f,array2,'un',0); out = cat(2...

9 years ago | 0

| accepted

Answered
How can I replace elements in a vector if a certain condition is true?
other variant: A = [-5 0 0 0 0 1 0 1 0 0 0 -3 0 0 0 1 0 0 1 0 0 1 0 -1 0 0 0 1 0 0 1] out = A(:); As = sign(A(:)); ...

9 years ago | 1

| accepted

Answered
How do i count unique elements in two table columns?
A = readtable('A.csv'); A.Properties.VariableNames = {'std_name','class','School'}; [g,ii] = findgroups(A.class); o...

9 years ago | 1

Answered
How do i calculate the Number of records that exist in both tables?
A = readtable('A.xls'); B = readtable('B.xls'); na = size(A,1); nb = size(B,1); Per1 = sum(ismember(A,B))/na*100...

9 years ago | 0

| accepted

Answered
transform a 3d matrix into cell array
Mycell = num2cell(Mymatrix,[1 2]) or Mycell = squeeze(num2cell(Mymatrix,[1 2]))

9 years ago | 4

| accepted

Answered
How Do i Sort rows in tables based on unique rows dictionary ?
[l0,iB] = ismember(A.con_name,B.con_name); dictionary_table = A{l0,3}; A_new = A(l0,:); B_new = B(iB(l0),:); [...

9 years ago | 0

| accepted

Answered
How do i sort table rows based on other table rows ?
[~,ii] = ismember(A.num,B.num); B_sorted_as_A = B(ii,:);

9 years ago | 0

| accepted

Answered
How do I create a vector with the number of repetition of a category?
X=categorical({'A','B','A','C'}); s = findgroups(X); i4 = accumarray(s(:),1); Z = reshape(i4(s),size(X)); or ...

9 years ago | 0

| accepted

Answered
Select row from matrix based on month with datenum
Please attach file with your datas (A and B): out = B(A(month(datetime(B(:,1),'InputFormat','yyyy-MM-dd'))) > B(:,9),:);

9 years ago | 1

| accepted

Answered
How do I separate the third column of a 12x3 matlab variable, into 3 different variables based on the numbers in the first two columns preceding it?
a0 = [0 100 200]; A = [a0(randi(3,12,2)),randi(125,12,1)]; % Let A - your array [12 x 3] conds = [1000 2000 3000]; %...

9 years ago | 0

Answered
How to select an array without element i
n = numel(a); V = reshape(nonzeros(repmat(a,1,n).*~eye(n)),[],n)

9 years ago | 0

Answered
Different results using .* on two computers
use bsxfun(@times,a,b) % here a - double array [1 x 1001], b - double array [5 x 1001]

9 years ago | 0

Load more