Answered
Median that ignores Nans
Out = arrayfun(@(i1)median(In(~isnan(In(:,i1)),i1)),1:size(In,2));

15 years ago | 1

| accepted

Answered
Regarding Interpolation( vertical)
In = DataInput; % Array 4D [a b oldc d] = size(In); newc = 15; Out = zeros([a b newc d]); for j4 = 1:d d1 = resh...

15 years ago | 0

Answered
Matrix evaluation at a collection of indices
idx = sub2ind([m n],i1,j1); U = zeros([m n]); U(idx) = Z(X(idx),Y(idx));

15 years ago | 1

| accepted

Answered
Nested Loops issue
variant 1 c = PP.AII; sr1 = sum(cell2mat(cellfun(@(x)sum(cell2mat(arrayfun(@(i1)d(c{i1})'*x(c{i1},c{i1})*d(c{i1}),1:length(...

15 years ago | 0

Answered
Extraction a certain part out of Matrix
My favorite version :) all is tired of me X = rand(20,1)>.35 In = X(:)'; idx = [strfind([0 In],[0 1]);strfind([In 0],...

15 years ago | 0

Answered
count number of values between NaN
more variant a1=In(:)'; a1(isnan(a1)) = 0; out = diff([strfind([0 a1],[0 1])-1;strfind([a1 0],[1 0])])';

15 years ago | 0

Answered
Writing mutiple data files in a single text file
out = []; for i1 = 1:50 fid = fopen(['w' num2str(i1) '_0.txt'],'r'); C = textscan(fid,'%f %f','Headerlines',1); ...

15 years ago | 0

Answered
Decrementing an Array
? Ds = cumsum([n;-ones(max(n),length(n))]); Ds(Ds<0)=0

15 years ago | 0

| accepted

Answered
Structure of Strings
bayesPosParams.distribution = {'normal'; 'kernel'}; bayesPosParams.prior = {'empirical'; 'uniform'}; bayesPos...

15 years ago | 2

| accepted

Answered
search a particular number in a cell array and return the index of the cell array that is found
correct out = find(~cellfun(@(x)isempty(strfind(x(:)',157536)),cc.PixelIdxList))

15 years ago | 0

Answered
how to write a function to find max & min value in array
try it function [ma mi] = alifun(A) aw = A(:); ma = aw(1); mi = aw(1); for i1 = 2:numel(aw) if ma < a...

15 years ago | 4

| accepted

Answered
Rotating a Vector
complex vR = v*[1;1i]*exp(-1i*theta*pi/180)

15 years ago | 1

| accepted

Answered
Sine generation with variable frequency and amplitude
k= zeros(1,100); k(1:90) = sin(linspace(0,2*pi,30))'*[2 1 3]; EDIT k= zeros(30,100); k(:,1:90) = reshape(permute(repma...

15 years ago | 0

Answered
How to get x,y coordinates of each pixels in a connected component ??
st = regionprops( I2, 'PixelList'); xy=cat(1,st.PixelList) xy(:,2) = abs(xy(:,2) - size(I2,1)) + 1 plot(xy(:,1),xy(:...

15 years ago | 4

Answered
Problem using the erfi function from Mupad in Matlab command Window
correct function out=erfi(t) out = arrayfun(@(i1)double(feval(symengine,'erfi',t(i1))),1:length(t)); end EDIT funct...

15 years ago | 0

Answered
removing area
STATS = regionprops(CC,'PixelIdxList','Area'); I2(cell2mat(cellfun(@(x)x',{STATS([STATS.Area]<100).PixelIdxList},'un',0)))=...

15 years ago | 0

| accepted

Answered
left characters of a string
name = 'Microsoft' out = name(1:6)

15 years ago | 2

| accepted

Answered
Solve with predefined parameters
fun = @(a,b,c)roots([a b c])

15 years ago | 0

Answered
Plotting set of data(3D)
data =[0,1,1;0,2,1.02;0,3,1.11;0,4,1.21;0,5,1.30;0,6,1.4;0,7,1.59;0,8,1.78; 10,1,1;10,2,1.11;10,3,1.35;10,4,1.62;10,5,1.95;1...

15 years ago | 0

| accepted

Answered
Categorise pixel gray values?
my variant ( *EDIT* ) A = randi(255,10); x = 0:51:255; x(end) = x(end)+100*eps; [n nb] = histc(A(:),); B=A; B(:)=nb...

15 years ago | 0

Answered
Function output
variant function out = foo(test) out = [test(:)',5]; end 2. You have: function [test; out] = foo(test) but we n...

15 years ago | 0

| accepted

Answered
sub2ind problem for matrix
idx=sub2ind(size(I),r(:,1),r(:,2))

15 years ago | 0

| accepted

Answered
How do I obtain the end of month dates for a time interval?
d = [726864,734169] dv = datevec(d(1):d(2)); d2 = unique(dv(:,1:2),'rows'); dm = eomday(d2(:,1), d2(:,2))

15 years ago | 0

| accepted

Answered
Independence Day weekend puzzler
str2num(num2str(10.^(length(x)-1:-1:0)*x'+1)')' *ADD* z = 10.^(numel(x)-1:-1:0)*x'+1 y = round(rem(fix(z.*10.^-(fix(log1...

15 years ago | 1

Answered
Sorting and functional arithmetic of two vectors
lin = 1:length(x); idx=sortrows([repmat(lin',1,2);nchoosek(lin,2)],1); ouridx = idx(abs(sum(x(idx),2))==10,:); y = rand(...

15 years ago | 0

Answered
Vectorizing nested for loops
bsxfun(@rdivide,phi,(1+(2:rho))') here phi vector row or use first row of 'phi' matrix bsxfun(@rdivide,phi(1,:),(1+(2:rho...

15 years ago | 0

| accepted

Answered
create an array
rand(200,400)*7

15 years ago | 0

| accepted

Answered
Simple Matlab Operation
*READ* <http://matlab.wikia.com/wiki/FAQ> Var4 = num2cell([1 2 3]) [Var1, Var2, Var3]=Var4{:}; *BUT* it's don't useful

15 years ago | 1

| accepted

Answered
Can I stop MATLAB when it's being busy?
Ctrl+Break

15 years ago | 2

Answered
deriving surface equation form data on a table
BHv= [1,2,3,4,5,6,7,8]; fiv= [0,10,20,30]; h = rand(length(BHv),length(fiv))*30+10; [fim BHm] = meshgrid(fiv,BHv); ...

15 years ago | 1

Load more