Answered
Checking many matrices for identical values
eg: A - your data cell array (in this is case with size 1 x 5) within double array 3 x N A = cellfun(@(x)[1:size(x,2);x]...

14 years ago | 0

Answered
repeating elements of a vector
x = arrayfun(@(a,b)a(ones(b,1)),lambda,ng,'un',0) lambda_long = cat(1,x{:}) add eg: lambda = [14 5 89 47]' ng...

14 years ago | 3

Answered
store the output of a for loop in an array
q = arrayfun(@(n)quad(@(x)cos(x)./sqrt(1+sin(x)),0,n),0:0.1:pi/2);

14 years ago | 0

Answered
how to find the area of black region in image....?
s = regionprops(YourImage == 0,'Area','PixelIdxList') add I = imread('44298455.png'); i0 = im2bw(I,graythresh(I));...

14 years ago | 1

Answered
creating a matrix from different sized arrays
x = [100 155 195 215 235 295]; y = 0:1; [ii jj] = ndgrid(y,x); a = eval(['reshape({',sprintf('mm%dg%d,',[jj(:),ii(:)]...

14 years ago | 0

| accepted

Answered
save data in a tabel with some column
data = ... dataset({[64, 76; 45, 12],'X','Y'},'ObsNames',cellstr(num2str((1:2)','%-d.'))) OR dataset({[(1:2)',[64...

14 years ago | 0

Answered
sorting rows
time1 = rand(8,1); yourmatrix = randi(30,8); solution: [id,id] = sort(time1); out = yourmatrix(id,:) ...

14 years ago | 0

| accepted

Answered
Multiplying certain dimensions of two 3D matrices
Idea of Sean de Wolski C = squeeze(sum(sum(bsxfun(@times,a,permute(b,[1 2 4 3]))))) or s = size(a) C = squeeze(s...

14 years ago | 1

| accepted

Answered
Removing elements from matrix
data=data(data(:,2)>=0.18,:); *ADDED* after Marin's comment simple example data1 =[... 2 3 5 8 10 ...

14 years ago | 0

| accepted

Answered
Problem using subs in syms with matrix
b = sym('b',[3 1]) a = sym('a',[3 1]) q = sym('q',[3 3]) a1 = [1 2 3]'; b1 = [4 5 6]'; q1 = [1 9 0; 2 3...

14 years ago | 0

| accepted

Answered
String Copying without Spaces
a = 'a b c d' b = regexprep(a,' ','') or b = setdiff(a,' ') or b = f(~ismember(a,' ')) or b = strre...

14 years ago | 0

| accepted

Answered
Replace multiple values
use function |regexprep| eg: c = {'c:\cookies.m'; ... 'c:\candy.m'; ... 'c:\calories.m'}; ...

14 years ago | 0

| accepted

Answered
pick arrays from matrix with condition
I = cumsum([true;diff(a(:,1))~=0]); ii = fullfact(size(a)); out = accumarray([I(ii(:,1)), ii(:,2)],a(:))

14 years ago | 0

| accepted

Answered
is it possible to use "find" to process every element of an array without loop
eg: a = randi(9,7,1); X = randi(9,12,1); solution: [I,J] = find(bsxfun(@lt,X,a.')); out = accumarray(J,I,[],@...

14 years ago | 3

Answered
How to find the two nearest values related to a constant
a=[1250 2320 3520 4650 5550 6760]; b= 3700; [~,e] = histc(b,a) out = [a(e+(0:1)) ; e+(0:1)]

14 years ago | 2

Answered
Combine two different matrices to create one new matrix of all matrix combinations
eg: M = 3; K = 10; WT_energy_supply = randi(10,10,4,M); PV_power_output = randi([10 50],10,4,K); %solution ...

14 years ago | 1

Answered
dimension mismatch error
pre-allocation: xmean = zeros(200,size(allsamples,2)); OR: xmean = bsxfun(@minus,allsamples(1:200,:),mean(allsample...

14 years ago | 0

Answered
Build matrix with other matrices.
z = {A,B,C,D,F,G}; out = zeros(6,8); for jj = 1:numel(z) [i1 j1] = size(z{jj}); out(1:i1,1:j1) = out(1:i1,...

14 years ago | 1

Answered
Algebraic Problem in writing the function for LSQNONLIN tool in the Optimization Toolbox
use function |lsqcurvefit| eg: A = .5; B = 4.1; C = .6; D = .6; x = (.01:.01:1)';y = (.01:.01:1)'; z = A*...

14 years ago | 0

| accepted

Answered
Create matrix from combination of two other matrices
eg: Mtype1 = arrayfun(@(ii)randi(randi([5 10]),5),(1:5).','un',0); Mtype2 = arrayfun(@(ii)randi(randi([10 50]),5),(1:10...

14 years ago | 0

| accepted

Answered
Find a element and return indices of a array 3D
clear size % ;) c = find (tmis == name); [a b d] = ind2sub(size(tmis),c);

14 years ago | 3

| accepted

Answered
Given the element in a matrix, how to get the corresponding element in cell array?(cell2mat, mat2cell)
eg A = arrayfun(@(x)randi(12,randi(6),6),1:7,'un',0) B = cat(1,A{:}) I=17;J=1; B(I,J) %solution idx = cu...

14 years ago | 0

| accepted

Answered
how to store specific pixels after scanning the image with a mask
h = cell(1,5) h{1} = [1 0 1;1 0 1;0 1 0]; h{2} = flipud(h{1}); h{3} = h{1}; h{3}([8,9]) = [0 1]; h{4} = h{2}; h{4}...

14 years ago | 0

| accepted

Answered
Expand vectors of matrix, but a different number of times each vector
C=[3 0 0 2]; D = arrayfun(@(x)[zeros(x==0),ones(x)],C,'un',0); D = blkdiag(D{:}); D = D(any(D,2),:); or D = c...

14 years ago | 0

Answered
How to enter simple function for converting Fahrenheit to Celsius?
CelsiusToFahrenheit = @(c)c*9/5+32 eg >> CelsiusToFahrenheit(15) ans = 59

14 years ago | 3

Answered
extract numbers from string in a cell
with using function |regexp| regexp(a,'\d*','match') or: b = {'TT21abc.def' 'sdfsdf34435afafsd.,.,343...

14 years ago | 0

Answered
Inserting zero rows and columns into matrix efficiently
A = [1 2 3; 4 5 6; 7 8 9]; pointer = [1 3 4]; pointer_master = 1:5; p = ismember(pointer_master,pointer); M ...

14 years ago | 0

| accepted

Answered
edit-rectangle box for each word
i0 = imread('image1.bmp'); i1 = im2bw(i0,graythresh(i0)); i2 = imfill(i1,'holes'); s = regionprops(i2,'Area','Boundin...

14 years ago | 0

| accepted

Answered
How to know the location of the minimun value from a vector?
A = [0.2008 0.2011 0.2011 0.1979 0.2003] [c,idx] = min(A) for matrix eg: A = rand(8); solutio...

14 years ago | 0

| accepted

Answered
reshaping a set of data
d = {'31/11/2011' 42.333 127.111 2.1 '31/11/2011' 43.333 123.111 2.3 '01/1/2012' 42.333 12...

14 years ago | 0

| accepted

Load more