Answered
Creating a row vector where the index of the vector is not equal to its element value
function v = int_col(n) v = randperm(n)'; t = v == (1:n)'; if any(t) ii = [find(~t,1,'first');find(t)]; ...

11 years ago | 0

| accepted

Answered
Reading numbers from a text file
f = fopen('data_in_your_format.txt'); c = textscan(f,'%s','delimiter','\n'); fclose(f); c = c{:}; [~,~,~,z] = rege...

11 years ago | 1

Answered
Fast way to 2D data thinning
X = randi([5,100],20,1); Y = randi([-100,10],20,1); trld = 10; % threshold n = numel(X); ii = nchoosek(1:n,2);...

11 years ago | 0

Answered
Convert Integer Array to Binary Array
intArray -> (bitArray, nBit) intArray = [3 2 1 7 6 2 5]; [~,nBit] = log2(intArray); bitArray = cel...

11 years ago | 5

| accepted

Answered
Alternating equations every other row
B = diff(A(:,[1,2]),1,2).*(-1).^(1:size(A,1))'

11 years ago | 0

| accepted

Answered
I need to display a data
% data - your data; first column - data+time, second - Power data = [timeprac1,P]; v = datevec(data(:,1)); a = date...

11 years ago | 1

| accepted

Answered
How to build-up a column from top to bottom
u=[]; for ii =1:10 a = rand(1); u = [u;a]; end

11 years ago | 0

Answered
Quick way to sum array elements based on flag in another array?
desired = flip(accumarray(cumsum(lost(end:-1:1)~=0)',clean(end:-1:1)),1)'; or desired = accumarray(cumsum(xor([0,diff(...

11 years ago | 1

Answered
corresponding elements of a setdiff of another variable
x = X(~ismember(Y,p)); or [~,ii] = setdiff(Y,p); x = X(ii);

11 years ago | 0

| accepted

Answered
How to find same elements in a cell array?
a = {[1,2,4,5] [1,4,2,5] [1,2,4,5] [4,1,5,2,1] [1,2,4,5] [1,4, 2,5]}; a = a(:); [a1,b,c] = unique(cellfun(@char,a,'un',0...

11 years ago | 2

Answered
Need to improve efficiency in this code, which multiplies a 3D matrix by a 2D one
W = reshape(W_rsT,size(W_rsT,2),[]).'; q1 = squeeze(q); w_pre = reshape(W*q1,[num_x, num_y,1,f_N]);

11 years ago | 0

| accepted

Answered
How to use histc for multiple array
a = cellfun(@(x)histc(x,1:0.5:10),F,'un',0); out = mean([a{:}],2);

11 years ago | 0

Answered
How to use use histc in multiple array
a = cellfun(@(x)histc(x,1:0.5:10),F,'un',0); out = mean([a{:}],2);

11 years ago | 0

Answered
How to plot a chart(e.g bar chart) given a dublicate x values?
[a1,~,c1] = unique(time_duration); A1 = accumarray(c1(:),Altitude(:)); bar(a1(:),A1(:));

11 years ago | 1

| accepted

Answered
Rearranging matrix based on coordinates
A = accumarray([y(:),x(:)],mass(:))

11 years ago | 1

| accepted

Answered
The input value can be represented by the values of a curve?
x = [0 25 50 70 80 100]; y = [0 5 7 9 10 11]; a = polyfit(x,y,3); c = polyval(a,min(x):max(x)); b = 1; z...

11 years ago | 0

| accepted

Answered
combining three cell array of different sizes
d = cell(3); d(:,1) = a; d(1,2:end) = [b,c];

11 years ago | 1

| accepted

Answered
finding index of precise value
d = datenum(Time); vt = datevec(d); out = find(vt(:,6) == 0);

11 years ago | 0

| accepted

Answered
Help correcting a messy time series data
d = [ 1998 12 14 6 1999 01 01 5.2 1999 01 02 4.3 1999 01 02 5.0 1999 01 02 4.1 1999 01 03 3.8 ...

11 years ago | 0

Answered
how to check if two elements are in a row of a matrix?
ii = fullfact([size(A,1),size(B,1)]); t = arrayfun(@(i1)sum(ismember(B(ii(i1,2),:),A(ii(i1,1),:))),(1:size(ii,1))') < 2; ...

11 years ago | 0

Answered
Solve function with integration of function of variable
Maybe so? out = fzero(@(x)integral(@(y)exp(-y),0,x)-.5,.5);

11 years ago | 0

Answered
Matrix operation with equation.
A = 1./(1+exp(-I));

11 years ago | 1

| accepted

Answered
Selecting a region from a 3D matrix and replacing the values there.
z = zeros(10,10,10); % Let your array ii = [3 4 2]; d = 5; c = arrayfun(@(x,y)x:y,ii,ii+5,'un',0); z(c{:}) = 1;

11 years ago | 0

Answered
How to extract all similar row of matrix A to matrix B
C = A(ismember(A,B,'rows'),:);

11 years ago | 0

Answered
How to find the most similar row in matrix A to matrix B
variant A=[1.2 2.0 3.3;1.2 2.0 3.2;1.1 2.1 3.3]; B=[1.1 2.0 3.2]; a = sqrt(sum(bsxfun(@minus,A,B).^2)); [~,t] ...

11 years ago | 0

| accepted

Answered
How to extract specific entries from a matrix?
A = randi(2000,100001,7); % let this is your data out = find(A(:,2) == 5);

11 years ago | 0

Answered
Outputting cumulative sum for Cell array with strings and numbers
Cell1={ 'A1' 5 'A2' 1 'A3' 2 'A4' 4 'A5' 1 'B1' 2 'B2' 6 'B3' 17 'B4' 8 'B5' 3 'C1' 7 'C2'...

11 years ago | 0

| accepted

Answered
how to convert binary string to m ary numbers?
I agree with Guillaume. But my variant: sb2 = '1000010001110010'; s = [repmat('0',1,mod(-numel(sb2),3)),sb2...

11 years ago | 0

Answered
How can I calculate average values of one data according to specific indexes of same size?
n = xlsread('path_and_name_your_file_data.xlsx'); out1 = accumarray(n(:,1),n(:,2),[],@mean); out = [n(:,1),out1(n(:,1))]...

11 years ago | 1

Answered
How to merge first elements from 2 array into an new array?
AB = [A;B]; out = AB(:)';

11 years ago | 0

Load more