Answered
how remove from a cell array, the words in an other cell array
w2 = word(cellfun(@ischar,word)); out_str1 = strjoin(w2(~ismember(w2,stopwords_cellstring)),' ');

9 years ago | 1

| accepted

Answered
nested for loops don't work
matrix=zeros(3,3,6); for k=1:6 for i=1:3 for j=1:3 matrix(i,j,k)=i+j+k; end ...

9 years ago | 0

| accepted

Answered
how find occorrences of words in a cell array
[~,c] = ismember(word,uniqueWord); out = [uniqueWord, num2cell(accumarray(c,1))];

9 years ago | 1

| accepted

Answered
Deleting specific colums in a matrix
out = M(~ismember(M(:,[1,3]),[3,5]),:);

9 years ago | 0

Answered
Compare two arrays based on indexes
M = [A,B]; V = [v1,v2]; C = [200,100]; out = C(ismember(V,M,'rows')+1);

9 years ago | 1

Answered
How to tabulate struct fields of cell arrays using nested for loops
Let |a| - your cell array. names = fieldnames(a{1}); b = cellfun(@(x)struct2cell(x)',a,'un',0); b = num2cell(cat(1,...

9 years ago | 0

Answered
For Loop using two variables
Vrf=0.1:0.1:10; V = @(x)(58.6-x:.1:58.4+x)'; W=@(x)1 ./ (pi.*x.*sqrt(1 - ((V(x)-58.5)./x).^2)); x = arrayfun(V,Vrf,'u...

9 years ago | 0

| accepted

Answered
How to create vectors in the for loop
n = 47; nn = n - 1; B = A(:)*2/nn*(0:nn) - A(:); % R2016b or later B = bsxfun(@minus,A(:)*2/nn*(0:nn...

9 years ago | 0

Answered
Sum over rows in a matrix for specific numbers in the last column
My ruble: ii = cumsum(diff([0;A(:,end)])~=0); [rs,cs] = ndgrid(ii,1:size(A,2)-1); result = accumarray([rs(:),cs(:...

9 years ago | 2

Answered
90 days correlation for loop
Use function |movstd| if you have MATLAB R2016a or later. rst = movstd(Aseries(:,1),[0 window]); condstdAseries = rst(1:...

9 years ago | 0

| accepted

Answered
How to compare one row of four matrices with all other rows of these matrices?
NSE2014 =[ 0.2733 0.2930 0.2930 0.2930]; RMSE2014 =[ 0.6939 0.6797 0.6...

9 years ago | 1

| accepted

Answered
The most efficient way to add a new column or new row to a sparse matrix
% Adding a new row to the end of the matrix A: A(end+1,[190 200]) = [7 89]; % Adding a new column to the end of ...

9 years ago | 0

Answered
how to create a matrix from a loop using other matrix
out = d.*c; t = d ~= 0; cc = out(t); out = cc(cumsum(t));

9 years ago | 0

Answered
How can I store the values in a matrix while using for loop?
k=1.5:0.1:3; n = numel(k); ws=zeros(1,n); dof=zeros(1,n); for ii=1:n ws(ii)=22+4+7+k(ii); dof(ii)=2+...

9 years ago | 0

Answered
Prevent repeating number in any matrix row
[~,out] = sort(rand(2,5),2);

9 years ago | 1

Answered
financial time series time with milliseconds
a = readtable('rev2.xlsx','ReadVariableNames',false); T = cell(2,1); T{1} = a(:,1:3); T{2} = a(~isnat(a{:,4}),4:end);...

9 years ago | 0

Answered
How can I fix my code so that it evaluates matrices of all sizes?
Pos = sum(B(:)>0) Neg = sum(B(:) < 0) Zro = sum(B(:) == 0)

9 years ago | 0

Answered
Sorting a cell containing character vectors
A={ '3-aaa' '2-bbb' '1-abc' '10-acb' '21- cab'} [~,ii] = sort(str2double(regexp(A,'\d+','match','on...

9 years ago | 0

| accepted

Answered
Summing values for duplicate rows and columns
A = accumarray([[1 2 3 1]',[1 1 2 1]'],[10 50 25 90]',[],[],[],1);

9 years ago | 0

| accepted

Answered
How to count values based on date
MATLAB R2016b and later T = readtable('Customer_Orders_Weekly.xls'); TT = table2timetable(T,'RowTimes','WeekOf___'); ...

9 years ago | 0

Answered
Extract a sub-matrix if the first or second column contains a specific number
ii = 4; Bii = A(any(A == ii,2),:);

9 years ago | 0

| accepted

Answered
How to Index Through a For Loop
B = [1 4 7 10; 2 5 8 11;3 6 9 12]; A = B; A(1,2:end) = A(3,1:end-1); or A = B; A(1,2:end) = A(1,2:end) - ...

9 years ago | 2

Answered
Looping and average through column values of a CSV
For MATLAB >= R2016b T = readtable('Data_test.csv'); a = datetime(T.date_time,'I','dd-MM-yyyy HH:mm'); T.date_time = ...

9 years ago | 0

Answered
Create random numbers with specific fraction of a certain number.
p = [.3; .25; .1;.25; .1]*1000; z = (1:5)'; out = repelem(z,p); out = out(randperm(numel(out))); or with |Stat...

9 years ago | 0

| accepted

Answered
Calculate a matrix based on value from another matrices
n = size(P,2); pp = P < .05; C = sum(pp,2)/n; [i1,j1] = find(pp.*(1:n)); E = cellfun(@(x)strjoin(x,','),accuma...

9 years ago | 0

Answered
finding the duration of a sequence of data
d = csvread('case2.csv'); d1 = d(d ~= 0); t = d1 > 0; tt = diff([1;t(:)]) ~= 0; out = accumarray(cumsum(tt),d1...

9 years ago | 0

Answered
Correlation between two matrices with different number of rows and columns
[m,n] = size(A); [m1,n1] = size(B); GI = griddedInterpolant({(1:m)',1:n},A); AasB = GI({linspace(1,m,m1)',linspace(1,...

9 years ago | 0

Answered
Adding and substracting elements from different arrays element wise and repeatedly
Tank = [10000;ones(8759,1)]; Tank_out = cumsum(Tank + AddedWater - Demand);

9 years ago | 0

Answered
Which Loop Should I use?
B = cumsum(A==5) & cumsum(A==2,'revers') or B = cumsum(A==5) & flipud(cumsum(flipud(A==2)))

9 years ago | 0

Load more