Answered
combining planes of data
M = cat(3, plane1, plane2, plane3,[more planes], plane512);

9 years ago | 1

Answered
Simple way to wrap quotes around input
str = ['''' str ''''];

9 years ago | 1

Answered
How to mirror matrix on the diagonal?
I2 = rot90(fliplr(I),-1);

9 years ago | 4

| accepted

Answered
I have a problem with a plot
plot(x, y1); hold on plot(x, y2) or plot(x, y1, x, y2)

9 years ago | 1

Answered
Low computation efficiency of simple sentence in MATLAB
Instead of X = repmat(lambda_old1,1,4).*[W1(:,i),W3(:,i),W2(:,i),W4(:,i)]; if might be faster to use X = bsxfun(@time...

9 years ago | 1

| accepted

Answered
How can I correct inhomogeneous intensity in image?
I = im2double(imread('blob.bmp')); y = mean(I(:, 1:100), 2); sigma = 30; % choosen by visual inspection G = f...

9 years ago | 0

| accepted

Answered
How can I solve the " Index exceeds matrix dimensions" error for the following code ?
Don't use negative indices like -2, they are always invalid. Valid indices in Matlab start with 1 and end with the number of ele...

9 years ago | 0

Answered
reading a .txt
First check if the encoding is ISO-8859-1, such that accents are read correctly: if ~strcmp(feature('DefaultCharacterSet'), ...

9 years ago | 0

Answered
Randomize three chosen arrays in matlab
A = [0,0,1]; B=[0,1,0]; C=[1,0,0]; X = [A; B; C]; x = X(sub2ind(size(X), 1:3, randi(3, [1, 3])))

9 years ago | 0

Answered
concatenate all value in a matrix into one number
This works even if the numbers are not single digits, i.e., in in {1,2,...,9} v = [10 20 4]; num = sscanf(sprintf('%d', v...

9 years ago | 0

| accepted

Answered
Connecting line between different points obtained from a for-loop
x = 1:20; y = x+2; plot(x,y,'*-')

9 years ago | 0

Answered
Matlab delete's value's from array
You remove all rows that contain a NaN in the line k(any(isnan(k),2),:)=[]; and then you assign the variables varia...

9 years ago | 0

Answered
how can i find the displacement in pixels for the 1st, 3rd and 5th squares in the picture
% number here found by visual inspection I = im2double(imread('1.JPG')); index_center = size(I,2)/2+100:size(I,2...

9 years ago | 1

| accepted

Answered
Change the default filling of a matrix
I do not know anyway to change the default behaviour of Matlab to fill the empty positions with zeros. So you have to do it in t...

9 years ago | 0

Answered
Trying to make a "snake" matrix?
N = 5; M = 9; T = reshape(1:M*N, [M, N])'; T(2:2:end,:) = fliplr(T(2:2:end,:));

9 years ago | 0

| accepted

Answered
Elimination of rows in array
A(A(:,1)+A(:,2) < A(:,3) | A(:,1)+A(:,2) > A(:,4), :) = [];

9 years ago | 0

| accepted

Answered
setting the position of the legend
The height of the box is the fourth parameter of the position. To reduce the size you can do the following: p = leg.Positio...

9 years ago | 0

Answered
How to make this complicated array
x = 5; y = 8; a(x,y) = 0; a([1:x 2*x:x:y*x y*x-1:-1:x*(y-1)+1 x*(y-2)+1:-x:x+1]) = 1:2*x+2*(y-2);

9 years ago | 0

Answered
Comparing a number matrix to certain values and storing it in another array / matrix
R = 5*rand(4); A = zeros(size(R)); A(R>=1 & R <= 2) = 1; B = zeros(size(R)); B(R>=3 & R <= 4) = 2;

9 years ago | 0

Answered
How to replace name with number
[~, ~, xnum] = unique(x, 'stable')

9 years ago | 0

Answered
How to change the language of 2015b (32bit) from english to chinese?
<http://de.mathworks.com/help/matlab/internationalization.html>

9 years ago | 0

Answered
Creating file names for save command
file_dir = 'C:\Users\mydir'; datestamp=char(datetime('now','TimeZone','local','Format','yyyyMMdd_HHmmss')); file_name...

9 years ago | 0

Answered
How to assign two values randomly among 2 variables?
idx = rand(100,1); sensor1 = c1; sensor1(idx>0.5) = c2; sensor2 = c1; sensor2(idx<=0.5) = c2;

9 years ago | 0

Answered
Find a pair of elements in a 3d matrix
Logical index: idx = A(:,:,1) == 0 & A(:,:,2) == 0; if you prefer a single index, you can use idx2 = find(idx); if...

9 years ago | 0

| accepted

Answered
optimization to get the least ratio of variables for two functions
You get the index of the minimum ratio A/B using [~, idx] = min(A./B);

9 years ago | 0

Answered
How to calculate compound interest?
If you have amount A at an interest rate of r, you have after one month A + rA = A(1 + r) after two months A(1+r) + ...

9 years ago | 0

Answered
How can I create shortcuts to layouts
You can set Shortcuts under Matlab > Preferences > Keyboard > Shortcut, but only for some pre-defined actions; changing the layo...

9 years ago | 0

Answered
Save multiple images in a folder
You have to use a new name for each image; e.g., for your i'th image: filename = sprintf('myimage%02d.png', i);

9 years ago | 0

Load more