Answered
How to create an indexing program that removes numbers between values
ii = find(test2 < 0,1 , 'first')-1; out = [test2(1:ii-1),test2(test2 == test2(ii))]; after last Andrew's comment t ...

9 years ago | 0

Answered
how to generate a random number between the range -50 to 50?
a = 10*(rand()-.5) or integer namber a = randi([-50,50])

9 years ago | 0

Answered
Repeating elements in a matrix.
A=zeros(3,4); n = size(A,1); A([1:n+1:end,n+1:n+1:end]) = 1 or t = true(3,4); out = tril(t,1) & triu(t);

9 years ago | 1

| accepted

Answered
create and fill new matrices every nth row of an initial matrix
Let A - your matrix [3060 x 2] out = permute(reshape(A',size(A,2),170,[]),[2 1 3]);

9 years ago | 0

Answered
Combining matrix of different dimension.
m1 = [2 2; 0 0]; m2 =[1 1;0 0]; m3=[2 2 2 2 ;3 3 3 3]; C = {m1,m2,m3}; [r,c] = cellfun(@size,C); m = ma...

9 years ago | 2

| accepted

Answered
How can I write a table from a matrix?
c = num2cell(pr,1); TTout = timetable(datetime(year1,month1,day1),c{:});

9 years ago | 0

Answered
How to get title for excelwrite code depend on data of specific column
Let |data| - your data [1431770 x 4]. a = accumarray(data(:,4),1); out = mat2cell(data,a,size(data,2)); for ii = 1:nu...

9 years ago | 0

| accepted

Answered
How to read in various columns from a text file and output a new txt file with specific data.
T = readtable('sampledata.txt'); TT = table2timetable(T); TTout = TT(:,[4,6]); TTout.Properties.DimensionNames={'Time...

9 years ago | 0

Answered
Subscripted assignment dimension mismatch for table variable
t1 = struct('f1','001','f2',2,'f3',3,'f4',4); t2 = cell2table(cell(4,4),'VariableNames',{'f1','f2','f3','f4'}); t2{1,:} ...

9 years ago | 0

Answered
Separate duplicates into different numeric matrices
a = [100 1 0.44 100 2 0.12 100 3 1.86 100 1 0.02 100 2 3.29 100 3 0.39 101 1 0.32 101 2 0.29 101 3 0.5...

9 years ago | 0

Answered
simulate hourly data from monthly data
Let TT - your data as <http://se.mathworks.com/help/matlab/ref/timetable.html?searchHighlight=timetable&s_tid=doc_srchtitle |tim...

9 years ago | 0

Answered
is there a way to implement a for loop in which matrix multiplication is exist?
ii = 1:r; t = 2:n; k = r*(n-1); Y = reshape(reshape(W(:,ii,t),[],k)'*reshape(x(:,ii,t-1),[],k),r,[]);

9 years ago | 0

Answered
I want count iteration in a binary matrix as follows.
out = diff(sort([strfind([0,I],[0,1]),strfind([I,0],[1,0]) + 1])); or out = accumarray(cumsum([1,diff(I)~=0])',1)';

9 years ago | 0

Answered
replacing the for loops
cxy = permute(repmat(SortDate(q,4:6),1,1,L),[1 3 2]); here |cxy| your arrays |c,x| and |y| as |cxy = cat(3,c,x,y)|

9 years ago | 1

| accepted

Answered
Really easy one how to quickly repeat columns in an array
a = 1:10; out = a(:)*ones(1,10);

9 years ago | 1

Solved


Insert Special character in character cell array.
input={'a','b','c'} then ans={'a','*','b','*','c'}

9 years ago

Answered
how to concatenate vetcors
t1 = ismember(k,v); v(ismember(v,k)) = temp; out = [v,k(~t1)];

9 years ago | 0

Answered
Can I index into a timeseries using time?
use your data as <http://se.mathworks.com/help/matlab/ref/timetable.html |timetable|> and use <http://se.mathworks.com/help/matl...

9 years ago | 0

Answered
Convert Cell to Struct
structtt = cat(1,tracks_array{:});

9 years ago | 3

| accepted

Answered
Integral of two function
Please read about function <http://se.mathworks.com/help/matlab/ref/integral.html?searchHighlight=integral&s_tid=doc_srchtitle |...

9 years ago | 0

Answered
given an mxn matrix, we've have to find the sum of elements for which the sum of their row no.(x) and column no.(y) is greater than m(total no. of rows)
out = sum(A(flip(triu(true(size(A)))))) or for MATLAB >= R2016b [m,n] = size(A); out = sum(A((1:m)' + (1:n) > m)) ...

9 years ago | 1

| accepted

Answered
how to calculate conditional probability
[a,~,c] = unique(values,'stable'); d = reshape(c,[],2); dm = min(d(:,2)); ny = accumarray(d(:,2) - dm + 1,1); [a1,...

9 years ago | 3

| accepted

Answered
How to extract multiple matches into separate rows?
T = readtable('test sheet.csv'); T_variance = varfun(@var,T(:,[1,end]),'G','Groups'); for plotted For_plot = ac...

9 years ago | 1

Answered
How can I count the number of zeros in a matrix until the value is non-zero?
B = sum(cumsum(A,2) == 0,2);

9 years ago | 2

Answered
How to get 15-min average values from 10 min average values?
TT = timetable(minutes(10*(1:10)'),randi([-20,100],30,1),'V',{'var'}); % Let TT - your data TT_15min = retime(TT,minute...

9 years ago | 1

Answered
How can I output multiple function outputs in a single vector (accessing all elements of an N-D array in a function)
output = cell(numel(siz),1); [output{:}] = ind2sub(siz,IND);

9 years ago | 0

| accepted

Answered
On re-arranging a matrix
omtx = 10*(1:6)' + (1:6); % your original matrix m = size(omtx,1); y = tril(true(m)); a = omtx.'; fmtx = y + 0; ...

9 years ago | 1

| accepted

Answered
how to find the equivalent resistance of two resistors in parallel and series
r1=1200; r2=1000; parallel = @(r1,r2)1/sum(1./[r1,r2]); % or: parallel = @(r1,r2)prod([r1,r2])/sum([r1,r2]); rt=paral...

9 years ago | 0

Answered
how to find parallel of resistors
Z_parallel = 1/sum(1./z); % here z - parallel resistors Z_series = sum(z); % here z - series resistors

9 years ago | 0

Answered
if elseif else in Table
ii = discretize(T.Time,[-inf,5,15,25,inf]) V = [5,15,25,30]'; T.TimeNew = V(ii);

9 years ago | 0

| accepted

Load more