Answered
How can I generate random number between 1 and 10, and at the same time I want to exclude number 3 & 6?
x = setdiff(1:10, [3, 6]); r = x(randi(numel(x)));

6 years ago | 4

| accepted

Answered
using 2 indexs for loop
for i=1:length(mHome) for k=1:2:size(mHome,2)-1 output1(i,k)=pdist([mHome(i,k:k+1);mBall(i,1:2)]); end end

6 years ago | 1

| accepted

Answered
I keep getting undefined function when preallocating
index = 1:30; % Preallocate S1QAmb = zeros(size(index)); % index has to be defined before it can be used for i = index S...

6 years ago | 0

| accepted

Answered
How to save the output of a loop with sequential file numbers.
for i:size(bounding_box, 1) face_crop = imcrop(I, [227,227]) filename = sprintf('%02d.jpg', 2*i - 1); imwrite(fac...

6 years ago | 0

| accepted

Answered
Common legend for multiple histograms in subplots
Set the FaceColor explicitly before calling legend: set(line1, 'FaceColor', 'r') set(line2, 'FaceColor', 'g') set(lin...

6 years ago | 0

Answered
how to create a video with a looming stimulus
This version works without exporting. In the code you can first choose 'test' to see if the sequence of images is what you want ...

6 years ago | 0

Answered
Incorrect number of output arguments for 'pre_test_fixpt'. Expected 1, but found 2.
You show code for pre_test, but the error is about pre_test_fixpt. Have a look at how you call this function in your code.

6 years ago | 0

Answered
Why am I getting two different plots for the exact same matrix?
Maybe it helps if you transpose the matrix to get it right.

6 years ago | 0

Answered
Converting third dimension of 3D matrix to 1xN object
struct(ii).Image = A(:,:,ii);

6 years ago | 0

Answered
Setting certain pixels in a grayscale image to RGB (red) for MIP
From the above discussion, I came up with this solution: % fake some data X = rand(10, 10, 23); N = prod(size(X)); ...

6 years ago | 1

Answered
Calculate weighted average of a 2D matrix
X = rand(376, 481); w = rand(1, size(X, 2)); Xw = bsxfun(@times, X, w); m = mean(Xw, 2);

6 years ago | 0

Answered
How to make axis invisible? But not xlabel and ylabel!
The trick is to create handles to the labels and use these handles to re-set the color of the labels after the color of the axes...

6 years ago | 0

Answered
i want code to convert image to text
You can use deep learning networks from the neural networks toolbox: nnet = alexnet; % Load pretrain...

7 years ago | 0

Answered
interpolating Sample data to finer increment
Vq = interp2(X,Y',Weights, -17.5:0.5:17.5, (-15:0.25:15)');

7 years ago | 0

| accepted

Answered
How to set the y-axis values to be only integers?
plot(x) a = axis; axis([a(1) a(2) 0 4]); set(gca, 'YTick', 0:4)

7 years ago | 2

| accepted

Answered
what is the difference between double and im2 double?
im2double converts to double and rescales the image to [0, 1].

7 years ago | 1

| accepted

Answered
Finding out values for elements of an array from corresponding array elements?
You can represent your weights as a matrix using NaN for the diagonal elements that do not exist: Weights = [NaN, 0.79,0.31...

7 years ago | 0

| accepted

Answered
Question about plotting/vectors
When x is a vector you have to use element-wise multiplication and division sigmax=(F/(pi*R))-((4*F*R.*x.^2)./(pi.*K)).*C

7 years ago | 1

| accepted

Solved


Sum all integers from 1 to 2^n
Given the number x, y must be the summation of all integers from 1 to 2^x. For instance if x=2 then y must be 1+2+3+4=10.

7 years ago

Answered
Resacaling an array to align and plot beside another
x = 1:600; A = rand(1, 600); y = 1:2:600; B = rand(1, 300); plot(x, A, y, B)

7 years ago | 0

Answered
how to use LUT form configuring matrix
Use your matrix as index to LUT: Mnew = LUT(M);

8 years ago | 0

Answered
need to gray-rgb transforming
The idea is to convert a color map to an RGB image stripe of size 1 x N, where N is the number of entries in the colormap, and t...

8 years ago | 0

Answered
How do I check that input is numerical?
Using isnumeric

8 years ago | 3

Answered
How can I extract all matrix element neighbors ?
You have to ensure that the indices are always valid, i.e., between 1 and the maximum number of rows / columns. For example, wha...

8 years ago | 0

Answered
Citing MATLAB Optimization Toolbox (BibTex reference)
I would use something like this @misc(MatlabOTB, key = {MATLAB Optimization Toolbox}, title = {MATLAB Optimizatio...

8 years ago | 4

| accepted

Answered
How can I repeatedly put a function result into itself, and get a matrix of the results?
N = 500; Y = zeros(1, N); % preallocate for speed Y(1) = myfun(1); for i = 2:N Y(i) = myfun(Y(i-1); end with my...

8 years ago | 0

Answered
How to add a string to a filename while saving plots
name = 'test'; Either newname = [name, '_angle']; or newname = strcat(name, '_angle'); or, as Stephen...

8 years ago | 1

Answered
Matching x-axis when two plots's axes are multiple of each other
With the x value of the bar command you can plot the two graphs on top of each other, as you initially intended: x = (0:20:...

8 years ago | 0

Answered
How to get the index of maximum value in each row of a matrix?
[~, q] = max(A, [], 2) ; p = (1:size(A, 1))';

8 years ago | 1

Load more