Answered
Simultanious for loop (two variables)
a = rand(1,2); b = rand(2,3); myColorMap = lines(length(a)); s = size(b); for jj = 1:length(a); hold on...

13 years ago | 0

| accepted

Answered
How can I make a loop inside a loop k time
Use function <http://www.mathworks.com/help/stats/fullfact.html?searchHighlight=fullfact |fullfact|> from |Statistics Toolbox| ...

13 years ago | 0

Answered
Vector where elements equals previous elements + 1
do as wrote Daniel OR end1 = 3; for jj = end1:-1:1 vector(jj) = jj; end

13 years ago | 0

| accepted

Answered
Getting cetral weighted value in an Array
a1 = sort(a(:)); out = median(a1([true;diff(a1)~=0])); ADD a1 = sort(a(:)); ii = find([true;diff(a1)~=0]); i2...

13 years ago | 0

Answered
Converting 2 symbolic expressions into a function handle
syms p q; num1 = 3* p^3 + 4*p*q + 5* p^2 + 1; num2 = 4* p^5 + 9*p^3*q + 2* p*q^2 + 2; f = matlabFunction([num1;n...

13 years ago | 0

| accepted

Answered
how to write cell values to a file from matlab?
use function <http://www.mathworks.com/help/matlab/ref/xlswrite.html |xlswrite|>: xlswrite('NameYourXlsFile.xlsx',out,1,'A1...

13 years ago | 0

| accepted

Answered
How do I create variable names from string variables
ID = {'height' 'height' 'height' 'speed' 'speed'}; data = [10;10;7;2.4;2.1]; [i0,i1,i1] = unique(ID); vars = cell2s...

13 years ago | 1

Answered
how can I create variable number of matrices (arrays) based on an arbitrary input.
use cell arrays: out = num2cell(A,2); % each cell - your new matrix

13 years ago | 0

Answered
Reshape a matrix according to specific columns.
A = {1 'a' 5; 1 'b' 6; 1 'c' 13; 2 'a' 8; 2 'b' 9; 3 'a' 10; 3 'b' 11; 3 'c' 12} [...

13 years ago | 0

Answered
how to concatenate in matlab?
A={'power'; 'load' ;'density'}; b={'mean';'std';'max';'min'}; [ii,jj] = ndgrid(1:numel(b),1:numel(A)); out = resh...

13 years ago | 0

Answered
Combine two cell arrays
X{1,1}=num2str([18;21;17;20;19]); X{1,2}=cellstr(['m';'f';'m';'m';'f']); strcat(X{:}) OR X{1,1}=num2cell([18...

13 years ago | 0

Answered
Warning: Explicit integral could not be found
using |Maple| and |Maple Toolbox|. >> A1=2940.543833;A2=177754.3553;B2=108.2941462;R12=0.967452952;S12=0.001155217; syms...

13 years ago | 0

Answered
count groups of elements and distances between them
A= [6 6 6 4 4 4 4 4 6 5 5 7 7 7 8 9 8 7 0 0 0 0]; a = A == 6 | A == 0; a1 = [0 a(:)' 0]; i1 = strfind(a1,[0 1]); i...

13 years ago | 1

| accepted

Answered
How to express integration of mutual information in MATLAB?
f = @(y) exp (-(y - 1) .^ 2 / 4) .* log2 (1 + exp (-y)); out = integral(f,-100,inf); or out = quadgk(f,-100,inf...

13 years ago | 0

Answered
How to make a matrix from several column vectors
norm1 = randi(10,5,1,30); % Let a = squeeze(norm1);

13 years ago | 0

Answered
Help with Multiple Loops
C = rot90(reshape(IntWL,117,[])); or n = numel(IntWL); k = 117; C = IntWL(bsxfun(@minus,n-k+1:n,(0:k:n-k)')); ...

13 years ago | 0

Answered
Visualize the depth matrix.
surf(z) % z - your "depth" matrix

13 years ago | 0

| accepted

Answered
Separating vectors into individual subsets for plotting
z = [nan nan nan nan 1 3 5 nan nan 3 4 nan 6 0 3 nan nan]'; z = z(:); if ~isnan(z(1)), z = [nan; z]; end; z1 = z(...

13 years ago | 0

Answered
the dimension of matrix minimum
[ii,ii] = min(A(:)); [i1,j1] = ind2sub(size(A),ii);

13 years ago | 1

| accepted

Answered
converting a text to number
str2double(strrep(C,'*',''))

13 years ago | 1

| accepted

Answered
Can arrayfun take multi-dimensional arrays as individual arguments?
I agree with Sean, but here example of use arrayfun (bad variant). arrayfun(@(ii)myfun(x(ii),y(ii),z(ii,:)),(1:numel(x))')...

13 years ago | 3

Answered
How to customize the answer of Matlab in advance?
n = numel(a); out = a(mod((2:n+1)-find(a == 1),n)+1);

13 years ago | 0

Answered
how to find the inverse of a 2x2xm matrix?
a(:,:,1) =[-0.6044-0.1389i, -5.2117-32.3236i;-0.0019-0.0205i, -0.6058-0.1386i] a(:,:,2) =[-0.5319-0.1475i, -4.6956-34.98...

13 years ago | 1

Answered
Consolidating row values from previous column duplicate values.
A = [1 1 3; 1 1 4; 1 1 7; 1 2 1; 1 2 6; 2 3 5; 3 6 4; 3 6 9; 3...

13 years ago | 0

Answered
problem with %d in MATLAB
for k = 1:22, imread(sprintf('%02d.dcm',k)); end

13 years ago | 2

Answered
Getting rows that correspond to second occurrence of a value
[a,b] = unique(x(:,1),'first'); out = x(b(histc(x(:,1),a)>=2)+1,2); or [~,i1] = unique(x(:,1),'first'); [~,i2] =...

13 years ago | 1

Answered
Sharing the values between vectors
f =[1,2,6,7,8,nan,nan,nan,nan; 3,4,nan,nan,nan,nan,nan,nan,nan; 5,9,nan,nan,nan,nan,nan,nan,nan]; out = n...

13 years ago | 0

| accepted

Answered
Generating a particular sequnce of numbers
out = nonzeros(triu(toeplitz(1:d))); or out = bsxfun(@minus,1:d,(0:d-1)'); out = out(out>0); or z = 1:d; ...

13 years ago | 1

Answered
Combining Data from different Cells in a cell array
strcat(xcoordinate',ycoordinate')

13 years ago | 2

Answered
How to make a general code for a set of pairs between 2 men and 3 women
M = {'M1' 'M2'} W = {'W1' 'W2' 'W3'} w = perms(1:numel(W)); w = w(:,1:numel(M)); s = size(w); out = mat2cel...

13 years ago | 0

| accepted

Load more