Answered
trying to combine cells
A = {X,Y,Z}; ii = hankel([0 5000],[5000 8000 10000]); C = arrayfun(@(x)A{x}(ii(1,x)+1:ii(2,x)),1:numel(A),'un',0); ou...

13 years ago | 0

Answered
how to use nanmean fxn with double precision elements?
t = isnan(Ax); A1 = Ax; A1(t) = 0; Ax_avg = sum(A1,2)./sum(~t,2);

13 years ago | 2

| accepted

Answered
Anyone can help me to improve this code?
*[EDIT]* n = 5; % R = [0 0 0 1 1]';% eg c = 2; % A1 = spdiags(-c*R,1,n,n); A = A1 ...

13 years ago | 0

| accepted

Answered
Vectorizing the creation of an offset vector
ii = find(C == BIN_1); offset_vec = zeros(size(C)); offset_vec(ii) = 1; offset_vec = cumsum(offset_vec); or (ADD) ...

13 years ago | 1

| accepted

Answered
solution for differntial equation?
Let your function: |funs| function y = funs(t,x) y = zeros(2,1); y(1) = -.0000358*(x(2)./x(1)); y(2) = .00000467*y...

13 years ago | 0

Answered
extract a variable from middle of a line of a .dat file with mixed text and numbers
f = fopen('your_data.txt'); c = textscan(f,'%s'); fclose(f); c1 = c{:}; d = str2double(c1(bsxfun(@plus,find(ismemb...

13 years ago | 1

Answered
merge two matrices together
ii = [40 40 40 40 41 41 41 41 42 42 42 42 43 44 43 44 43 45 44 44 44 48 45 49 45 50 49 51 50 51 51 52 ...

13 years ago | 0

Answered
how to get permutation of each rows of matrix
out = []; for j1 = 1:size(A,1) out = [out;unique(perms(A(j1,:)),'rows')]; end

13 years ago | 1

| accepted

Answered
How to return a mean value with NaN values in the matrix?
% 1) JumpHeightImpulse(JumpHeightImpulse < .5 | JumpHeightImpulse > 1) = nan; % 2) CD - your CombinedData m = ...

13 years ago | 0

Solved


Number of digits in an integer
Specifies how many digits in a given integer. Example: in=100 ==> out=3

13 years ago

Solved


Related Vectors
I have two vectors A & B. If the values in vector A is zero then the corresponding value in vector B should be zero. Example:...

13 years ago

Answered
finding submatrix and index
I1out = imdilate(I1,flipud(eye(min(size(I1))))); I2out = imdilate(I2,eye(min(size(I1)))); ADD after Mohammad Golam Kibri...

13 years ago | 0

Answered
changing position of numbers in a vector
out = unique(perms([1 1 0 0 0 0]),'rows'); or [EDIT] A = [1 1 1 1 0 0 0 0 0 0]; n = numel(A); b = nnz(A);...

13 years ago | 4

Answered
how can I write all for loop outputs in single matrix?
Try this construct out = []; for jj = ... % here your execution A = ... out = [out;A]; end

13 years ago | 0

Answered
Group numbers from excel column based on character
more variant a = [1 2 3 4 -2 -3 4 6 6 -3 -6 -5 -7 2 1 5] v = a > 0; v = v(:)'; ii = [strfind([0 v],[0 1]),strf...

13 years ago | 0

Answered
how can I cancel repeated results?
s = bsxfun(@times,M,vector); sout = unique(s,'rows','stable');

13 years ago | 0

| accepted

Answered
storing changing values in a loop ????
for ii = 10:-1:1 p{ii} = polyfit(x,y,ii); d(:,ii) = polyval(p{ii},x); end

13 years ago | 0

Answered
How to avoid for loop in specific case
Used of Jan Simon's idea. [EDIT] zn1=find(zn==1); ii = diff(zn1); o2 = zeros(size(zn)); out = zn; t = ii > 0.1...

13 years ago | 1

Answered
Spliting a date to day, month and year
de = {'14/2/1923', '8/2/1923'}; ymd = datevec(de,'dd/mm/yyyy'); out = ymd(:,3:-1:1);

13 years ago | 1

Answered
index of a sequence
[v,ii]= min([a;b]); t = accumarray(ii',(1:numel(a))',[],@(x){x}); [v2,i2]=cellfun(@(x)sort(v(x)),t,'un',0); sn = [v2{...

13 years ago | 1

Answered
How to fix looping?
v = 120; r1 = 1.8; x1 = 2.4; r2 = 3.5; x2 = 1.2; xm = 60; ns = 1800; ws = 188.5; s = [.0001;(.5:50...

13 years ago | 1

| accepted

Answered
Adding two different size matrices
A=ones(100,50); A2 = zeros(max(A)); A2(1:numel(A)) = A; B = A2 + A2';

13 years ago | 0

Answered
selecting multiple files from folder directly
variant q = dir('*.txt'); n = regexp({q.name},'^a1.*[1-3]_a.*','match'); out = n(~cellfun('isempty',n));

13 years ago | 0

Answered
Taking weighted means over matrices with missing data
M = [4 NaN 1 NaN; 5 3 8 NaN; 1 6 2 4; 8 4 7 2]; w = [0.4 0.3 0.2 0.1]'; t = isnan(M); M(t) = 0; out = (M*w)./(...

13 years ago | 0

Answered
vector comparison - find and replace
A = [2 4 5 1 8 9]; N = 2; t = diff(reshape(A,N,[])) > 0; C = reshape([~t;t],1,[]); or A1 = reshape(A,N,[]);...

13 years ago | 1

| accepted

Answered
Store cells into Matrix
[ii jj]=ndgrid(x1s,x2s); variables = permute([ii(:), jj(:)],[3 2 1]);

13 years ago | 0

Answered
Removing Duplicate Elements from Array sets
Let your array: K = [Kp Ki Kd] Knew = K(any(diff(K,1,2),2),:);

13 years ago | 0

| accepted

Answered
How can I define one variable of a 4-variable function, then compute the 3-dimensional integral?
try: h = integral3(@(x1,y1,z1)p(a,x1,x2,x3),-x,x,-y,y,-z,z);

13 years ago | 0

Answered
Substitute a polynomial into another polynomial??
p1 = [1 0 1 1]; p2 = [1 0 0]; n2 = find(fliplr(p2(1:end-1))); n1 = find(fliplr(p1(1:end-1))); n = n1*n2; pout...

13 years ago | 1

| accepted

Answered
how can we represent the histogram of a vector without using the hist function ?
eg X = randi(20,40,1); ii = [-inf 0:4:20 inf] out = sum(bsxfun(@lt,X,ii(2:end))&bsxfun(@ge,X,ii(1:end-1))) histc(X...

13 years ago | 0

Load more