Answered
Can a program be written that can sort a set of words alphabetically?
Is this homework? Otherwise just use sort words = {'a' 'z' 'foo' 'bar' 'unsorted' 'help'} sort(words)

10 years ago | 0

Answered
RGB color value of plotyy purple bars
Try get(b, 'EdgeColor') get(b, 'FaceColor') With Matlab R2012a, I get black bars and get [0 0 0] for EdgeColor and 'f...

10 years ago | 0

Answered
what does A(ones(3,1),:)) do?
>> A = [1 2 3] A = 1 2 3 To select the first row of A, all columns (:) >> A(1,:) ans = 1 2 ...

10 years ago | 1

Answered
In a specific range, finding the first value over a specific value and maximum value
It's not clear to me what you want. I've you want to enter vectors of different length and find the first value and the maximum,...

10 years ago | 0

Answered
gather data from different sections of each column
You only need numelselect values of rows: B = randi(90,numselect,1); Then use for i = 1:numel(B), D(:,i) = A(B(i):B(i...

10 years ago | 1

| accepted

Answered
what does this error means-"Function definitions are not permitted at the prompt or in scripts."?
To define a function, create a new m-file on the command line >> edit myfun.m write your function in this file, first no...

10 years ago | 1

| accepted

Answered
Find Maximum Values of a 3 Dimensional Matrix
Reshape the pages of F into separate columns, determine the max for each column and use ind2sub to convert linear indices to sub...

10 years ago | 1

| accepted

Answered
I need to make a program that generates random numbers between 0 and 9999 for 5 seconds, and stops if the number 2015 is generated. I must use the etime and fix functions.
After I've replaced Disp with disp the program works fine. Another way to solve the task would be the following program; it uses...

10 years ago | 0

| accepted

Answered
How can I designate an image which had been plot some points on to be an variable?
You can use the following function to draw a line in an image: function I = bresenham(p1, p2, I) %Draws a white line fro...

10 years ago | 0

Answered
Reversing plot data to fit experimental to simualtion data
You can use fliplr and add some offset in y direction. data = fliplr(data) + yoffset;

10 years ago | 0

Answered
Print results using fprintf in required format
fprintf accepts only a single format string: for i = 1:numel(X), fprintf('The value of X%d = %0.1f\n',i, X(i)),end

10 years ago | 0

| accepted

Answered
Display images in one figure
Use subplot: for i =1:Nimages I = ... % read ith image subplot(Nrows, Ncols, i), imshow(I) end

10 years ago | 0

| accepted

Answered
how to find predefined values indices in a matrix?
arrayfun(@(x) ST(find(ST(:,2)==x, 1, 'last'), 3), unique(ST(:,2)))

10 years ago | 0

| accepted

Answered
How can I convert a dicom image into tiff?
To convert to tiff (e.g., uint16 dicom to uint16 tif): I = dicomread('../../Downloads/CR-MONO1-10-chest'); imwrite(I, 'che...

10 years ago | 1

Answered
Any way to use fplot to draw multiple curves in the same figure?
fplot(@(x)[tan(x),sin(x),cos(x)], 2*pi*[-1 1 -1 1])

10 years ago | 0

| accepted

Answered
nested for loop keeping i constant through all, until end of j's
Use two for-loops: for i=1:4 fprintf('i = %d, j = ', i) for j = 1:4 fprintf('%d,', j) end fprint...

10 years ago | 0

Answered
How can I avoid plotting zeros in data?
Sample data: y = zeros(1,100); y(1:10:100) = 1 + rand(1,10); plot(y) hold on Select only non-zero values for plotting...

10 years ago | 1

| accepted

Answered
Finding all possible combinations of a matrix
val = 0:3; X = []; for i = val, for j= val, for k = val, for l = val, X = [X; [i,j,k,l]]; end, end, end, end or ...

10 years ago | 0

Answered
How can I find the top 5% values' index in a 3D matrix
X = rand(10, 10, 3); % sample data [~, idx] = sort(X(:)); Linear indices: idxtop5perc = idx(end-5*numel(X)/100+1:end) ...

10 years ago | 0

Answered
Error using plot, vectors must be of the same length
Use a loop to determine the chid and chi values for different t tall = t; for i=1:numel(tall) t = tall(i); ...

10 years ago | 0

| accepted

Answered
Attempting to Crop binary image
The image contains some spurious white points, e.g. at (950,3). You can delete them using erosion se = strel('disk',1) e...

10 years ago | 0

Answered
Undefined function or variable 'X'
In the example, a variable X is stored in mask.mat and bust.mat, that are assinged to X1 and X2, resp., after loading. If you do...

10 years ago | 2

Answered
surf(Z) Z= 11x9 double produces a 10x8 surface
The full matrix is shown by surf. The numbers define the outer points of each patch: consider surf([1 2; 3 4]) that draw...

10 years ago | 0

Answered
how to use 2d matrix to index into 3d matrix
Use linear indexing N = size(C,1)*size(C,2); idx = [1:N]+(ID(1:N)-1)*N; B = reshape(C(idx), size(C,1), size(C,2)); ...

10 years ago | 0

| accepted

Answered
Neighbouring Gray Level Tone Dependence Matrix
Have a look at <http://stackoverflow.com/questions/25019840/neighboring-gray-level-dependence-matrix-ngldm-in-matlab>. It includ...

10 years ago | 0

Answered
division of two matrices
bsxfun(@rdivide, A, B)

10 years ago | 0

Answered
Sort one set of data to correspond to another.
If b is an unsorted version of a, i.e., all elements in b occur once and only once in a, you can use [~, idx] = sort(b); ...

10 years ago | 0

| accepted

Answered
How to copy every 500 rows to a new variable?
Why do you want to create 60 new variables and double the data? That's not a good idea. You can keep your original data and just...

10 years ago | 1

Answered
why I get "out of memory" error when i use zeros(60000)?
You tried to allocate 60000*60000*8 = 28.8 GByte. That's seems to be too much for Matlab on your machine.

10 years ago | 2

Load more