Answered
counting number of onesin a matrix
a = unique(A); out = [a, histc(A(:),a)]; OR in rows: a = unique(A)' outrws = [a;cell2mat(arrayfun(@(x)histc(A(...

14 years ago | 0

| accepted

Answered
Computational problem
n=6; m=5; p = 2:(n-1); for j1 = numel(p):-1:1 cc(:,j1) = (2+(m*(p(j1)-1))):1:(m*p(j1)-1); end cc = cc(:...

14 years ago | 0

| accepted

Answered
Extract an array of doubles from a nested cell array
out = cell2mat(cellfun(@(x)x{2},X(:,9),'un',0))

14 years ago | 2

| accepted

Answered
matlab function
syms x y z f = [x*y*z; y; x + z]; v = [x, y, z]; R = jacobian(f, v); t = 1:3; Out = zeros([size(R),numel(t)]); ...

14 years ago | 0

| accepted

Answered
matrix unions
C = A C(~ismember(A,B)) = nan OR C = A C(setdiff(A,B)) = nan

14 years ago | 1

Answered
converting 3D matrix to 2D image
f = @(block_struct)dct2(block_struct.data); f2 = @(block_struct)idct2(block_struct.data); C1 = blockproc(HL31,[4 4],f); ...

14 years ago | 0

Answered
Obtaining an updated diagonal Matrices
N=20; itr = 300; i1 =... bsxfun(@plus,bsxfun(@plus,1:4:4*N,[0;3]),reshape(0:4*N:(itr-1)*4*N,1,1,[])); out = ze...

14 years ago | 0

| accepted

Answered
symbolic Integration in Matlab
syms r R1=sqrt(3)*(2*r.^2-1) R2=sqrt(3)*(2*r.^2-1) b = .7; S=2*pi*imag(int(exp(1i*b*R1)*r,r,0,1)*int(R2*exp(-1i*b*...

14 years ago | 1

Answered
trying to create a new vector from 2 vectors.
y = y(:); y1 = y1(:); y2 = [y(1:3); y1(4:end-3); y(end-2:end)];

14 years ago | 0

| accepted

Answered
New matrix from all based on some criteria
B = A(A(:,2) == 2,:)

14 years ago | 0

| accepted

Answered
Find row where cell value equals some defined value
eg data = {'1999Q2' '1999Q3' '1999Q4' '2000Q1'} out = find(~cellfun('isempty',strfind(data,'Q4'...

14 years ago | 3

| accepted

Answered
i get good fitting result from curve fitting toolbox, how can i convert it to program code?
try use |nlinfit| from |Statistics Toolbox|

14 years ago | 0

Answered
quad error
out = quad(@(x)10*ones(size(x)),0,5) OR out = trapz([0 5],[10 10])

14 years ago | 0

| accepted

Answered
quad function
i1 = @(t,T)(8*exp(-t/T).* sin(2*pi*t/T)).^2.*(t < T/2) f1 = @(T)quad(@(t)i1(t,T),0,T/2) % e.g. T = 10; out ...

14 years ago | 0

| accepted

Answered
Assign index value to bits in cyclic order
s = '11001011 01111010 10101010 10011001 01010101' p = rem(numel(regexp(s,' [01]'))+1,3) k = (0:2)' s1 = reshape(rege...

14 years ago | 0

| accepted

Answered
convert a vetor of hours into time
x = (0:23).'; n = numel(x); out = datestr([ones(n,1)*[2012 3 10] x zeros(n,2)],'HH:MM');

14 years ago | 1

| accepted

Answered
Optimizing the entries of a matrix. Finding an analytic solution as a function of the entries
eg abcd = reshape(randi(12,2,1)*[1,.35],[],1);

14 years ago | 0

Answered
How can I create overlapping subvectors?
out = x(bsxfun(@plus,(1:4).',0:2:numel(x)-3)) OR out = x(cumsum([(1:4).',2*ones(4,(numel(x)-4)/2)],2)) OR y=bu...

14 years ago | 0

Answered
For loop stops on error - how can I force to continue
Try use block <http://www.mathworks.com/help/techdoc/ref/try.html |try...catch..end|> in inside loop |for...end|

14 years ago | 2

| accepted

Answered
Symbolic toolbox help using solve command
hl = 1; hr = 0.1; g=9.81; syms s geneqn = s*((s - ((g*hr)/(4*s))*(1+(sqrt(1+((8*s^2)/(g*hr))))))... + 2*(sqrt((...

14 years ago | 0

| accepted

Answered
how to make an envelope of a signal?
Use |rand|, |randn|, etc. eg x = linspace(0,2*pi,300); sx = sin(x); out = sx + .2*(2*rand(size(x)) - 1); pl...

14 years ago | 0

Answered
Sampling data
eg x = randi(1000,100,1); out = x(10:10:end)

14 years ago | 1

| accepted

Answered
not take into account zeros in a graph
z = [3 0 2 0 0 0 5 0 2 0 0 0 4 0 1 0 0 8] [i1,i1] = find(z) plot(i1,z(i1));grid on

14 years ago | 0

Answered
how to find Mean Square Error in matlab?
what <http://en.wikipedia.org/wiki/Mean_square_error MSE> eg X = randi(1000,10,1); your_mse = std(X)^2/numel(X)

14 years ago | 0

Answered
erase rows and remember string of erased row
allh = cell2mat(allhigh(:,2:end)); alll = cell2mat(alllow(:,2:end)); k = any(allh < alll,2); allhigh(k,2:end) = {[]};...

14 years ago | 0

Answered
How to do this in MATLAB without for loops
*EDIT* n = 4; a = eval(['[',sprintf('x%d,',1:n),']']); [~,idx] = sort(min(a),'descend'); out = a(:,idx(1:2))

14 years ago | 0

Answered
question about linear simultaneous solutions
syms x y slv = solve(x+y-1,x*y-10,x,y)

14 years ago | 0

Answered
how to define a function in the command window using "@"
please read <http://www.mathworks.com/help/techdoc/ref/function_handle.html here> eg >> f = @(x)x.^2-3 f(54) f = ...

14 years ago | 0

| accepted

Answered
segregate data
out = reshape(P,numel(P)/2,[])' or out = mat2cell(P,1,numel(P)/2*[1 1]) or t = P < 100; out = {P(t) P(~t)}

14 years ago | 0

| accepted

Answered
Cell2mat conversion
C ={['QRSTUVWXYZ' '[\]^_`abcd' 'efghijklmn' 'opqrstuvwx']} out = C{1}(4,5) *ADD* on Harjan's comments C ={[...

14 years ago | 0

| accepted

Load more