Answered
Remove rows or cols whose elements are all NaN
out = A(all(~isnan(A),2),:); % for nan - rows out = A(:,all(~isnan(A))); % for nan - columns

13 years ago | 24

| accepted

Answered
Cut the last n of matrix row ?
a = (1:7)'; n = 2; A = a(1:end - n); or a(end - [n-1, 0]) = [];

13 years ago | 1

| accepted

Answered
IIR filter as amoving averege
EDIT out = filter([1 1 1]/3, 1, x(:)); out(1:2) = [x(1);sum(x(1:2))/2];

13 years ago | 0

| accepted

Answered
Insert a blank column every n columns
yourmatrix = randi(23,10,360); n = 6; yourmatrix(:,n:n:end) = nan; or a = randi(23,10,360);% your matrix n = ...

13 years ago | 0

Answered
Export dataset to excel including serial date numbers
Ds = datenum('30-Dec-2013') - 693960; If you have |Financial Toolbox|, you can use function |m2xdate|. Ds = m2xdate(da...

13 years ago | 0

Answered
How can I find out the diagonal elements of any matrics? Again i want to arrange it in row by row
b = spdiags(a).'; general case b = spdiags(a,-size(a,1)+1:size(a,2)-1).';

13 years ago | 0

Answered
subrutine to multiplication multidimensional matrix
use |<http://www.mathworks.com/help/matlab/ref/bsxfun.html bsxfun>| ADDED on |agustin darrosa|'s comment [EDIT] ;) if nu...

13 years ago | 1

| accepted

Answered
finding same values in matrix
A = randi(124,31,80); C = randi(50,30,81); cu = unique(C); [aa,ii] = ismember(A,cu); [i1,j1] = find(aa); out = ...

13 years ago | 0

| accepted

Answered
replacing the NaN with specific values
A1 = A(2:end,:); t = ~cellfun(@isnan,A1(:,2)); k = A1(t,2); A(2:end,2) = k(cumsum(t)); added on comment A1...

13 years ago | 1

| accepted

Answered
i got an error when i run this code ?
k = 1:5; x = 1:100; y = k'*log(x); plot(x,y);

13 years ago | 0

| accepted

Answered
replace nan with blank
out = abc(~cellfun(@isempty,abc)); or abc(cellfun(@isempty,abc)) = [];

13 years ago | 0

| accepted

Answered
How to average a multidimensional array with surroundings
k = reshape(1:9,3,[]) % your array k1 = [k(:,2),k,k(:,end-1)]; k1 = [k1(2,:);k1;k1(end-1,:)] out = conv2(k1,[0 1 ...

13 years ago | 0

Answered
Removing values form the Matrix
in your case: B = randi(100,10,62); A = B(4:5,:); B(end,:) = A(1,:); % your data [a,ii] = ismember(B,A,'ro...

13 years ago | 1

Answered
How to remove the pairing X value when Y is NaN?
X = [0 0.5 1 1.5 2 2.5]; Y = [2 NaN 7 8 NaN NaN]; XY = [X(:),Y(:)]; out = XY(~isnan(Y),:); % your case ...

13 years ago | 0

Answered
matrix row extraction help
x = randi(150,40,10); % your matrix out = x(7:7:end,:);

13 years ago | 1

| accepted

Answered
Linearly increasing groups of indices
out = bsxfun(@plus,[1;3;4],0:10:10*(floor(x(end)/10)-1));

13 years ago | 0

Answered
How to cleanup/fix my mapping of cell-array MATLAB code so I do not hit a recursive limit?
x = [1 2 3 -1]; d0 = 0:3; d = {[0 2] , [1 1] , 4:2:8, 6:3:15}; tp = x < 0; x(tp) = -(x(tp)+1); out = cell(...

13 years ago | 1

Answered
Need help processing this
out = cast((1:size(A,1))*double(A.*A),class(A));

13 years ago | 1

| accepted

Answered
Need help understanding arrays
for your case: A ([1:2,2:3]) for: A(1:2,2:3);% 1:2 - numbers rows, befor the comma % 2:3 - numbers co...

13 years ago | 0

| accepted

Answered
How do I use a for loop with excel
height = 5 for z = 1:18 if height == z s= xlsread('myexcelfile','sheet',sprintf('B%d',z)); end ...

13 years ago | 0

| accepted

Answered
Rounding to a specific number
x = randi([137,149],10,1); out = round(x/5)*5; ADD s = xlsread('yourfile.xlsx'); % data from Excel -> [140;155...

13 years ago | 0

| accepted

Answered
How to find maximum value for 3 iterative variables.
max1 = [-inf 0 0 0]; for p=1:6 for q=1:6 for z=1:100 a=2*p; b=5*q; ...

13 years ago | 0

| accepted

Answered
Using a string as a command?
eg: str = 'x.^2'; yy = str2func(['@(',char(symvar(str)),')',str]); use x = 0:10; out = yy(x); ADD str...

13 years ago | 0

Answered
moving averege of a matrix
out = conv2(A,[.5 .5],'same'); out(:,1:end-1);

13 years ago | 0

| accepted

Answered
operation array in cell
A1 = permute(A,[3 4 1 2]); B1 = permute(B,[3 4 1 2]); XY = Z; for ii = 1:size(Z,1) for jj = 1:size(Z,2) ...

13 years ago | 0

Answered
How to import data from text file to mat file directly with lebels
f = fopen('yourfile.txt'); c = textscan(f,'%s'); fclose(f); C = reshape(c{:},4,[])'; out2 = cell2struct([{C(2:en...

13 years ago | 0

Answered
why does xlsread deletes NaN for cells with text?
use [~,~,c] = xlsread(...) eg [~,~,c] = xlsread('yourfile.xlsx') out = zeros(size(c)) lc = cellfun(@(x)ischar...

13 years ago | 0

Answered
operation array in cell
out = A'; for jj = 1:numel(out) out{jj} = out{jj}*p(jj)+q(jj); end out = out';

13 years ago | 0

Answered
Separating a matrix into two matrices based on a value of one of the columns.
p = data(:,4) > 0; % here 'data' - your array out = {data(p,:), data(~p,:)}; if there is a negative value, then out...

13 years ago | 0

| accepted

Answered
targeting a single piece of data from an array
[z,ii] = min(x(:)); [rws,cls] = ind2sub(size(x),ii);

13 years ago | 1

Load more