Answered
generation of random numbers inthe specified range ?
your_vals = 8.75 + (9.50 - 8.75).*rand(100,1);

13 years ago | 0

Answered
Figures displaying differently in and out of MATLAB
In order to preserve appearance, you could use a vector graphics format, such as .svg or .eps, instead of .png which is a bitmap...

13 years ago | 1

| accepted

Answered
Ploting A square around minima of a matrix
x = rand(100,1); y = rand(100,1) [idx idx] = min(y); plot(x,y,'.') hold on; plot(x(idx),y(idx),'s','MarkerSize'...

13 years ago | 0

Answered
decrease num of for loops
old_v = 0; for ii = 1:8*8*8*8 [u v x y] = ind2sub([8 8 8 8],ii); u = u-1; v = v-1; x = x-1; y = y-1; ...

13 years ago | 0

Answered
Run an M-file multiple times
for ii=1:1000 your_m_file_name %the .m is not necessary end Provided you are in the directory your m-file resides...

13 years ago | 0

| accepted

Answered
Problem when assigning vectors
b = zeros(numel(f),1);

13 years ago | 1

Answered
need a time series
totHours = 72; totMin = 12; totSec = 21; totVals = totHours*60*60+totMin*60+totSec; hour_vec = cell2mat(arra...

13 years ago | 3

| accepted

Answered
Weird spaces undetected by strfind
This sounds like an encoding problem. To find out what encoding your installation of Matlab uses: feature('DefaultCharacte...

13 years ago | 2

Answered
Generate random's number?
nVals = numel(your_stream); your_val = your_stream(randperm(nVals,1));

13 years ago | 1

Answered
How to compare a matrix row by row with specified condition
Maybe not the most efficient thing around, but here goes: A=[ 5 0 10 15 0.021 5 0 15 20 0.011 10 15 ...

13 years ago | 0

| accepted

Answered
How to output as a vector
Still <http://www.mathworks.com/matlabcentral/answers/51950-coin-toss-game-simulation going at it>. What's the meaning of _N ...

13 years ago | 0

| accepted

Answered
datenum with time in time vector
I don't think you get the same number. Try diff(tt) and you will see that they are different. Also, use f...

13 years ago | 0

| accepted

Answered
transform a cell in a column
A = cell2mat(A);

13 years ago | 0

Answered
How to plot multiple qqplot (Observed vs. Simulations) on same single figure with same regression line?
You can't. Why would you want to do that? Even if you could, what would the meaning be? It's not a regression line. A straight l...

13 years ago | 0

| accepted

Answered
Can these operations be vectorized?
There are ways, but it will probably be slower. For loops are not necessarily bad. Look at the answer <http://www.mathworks.com/...

13 years ago | 0

Answered
what kind function of this? Fit Constant Probability?
_constProb_ is not a built-in function. You can look at the source code yourself edit constProb Or you can post it her...

13 years ago | 1

| accepted

Answered
how to add string matrix to numeric matrix?
You could use cell arrays: a={'rice';'corn';'wheat'}; b={3;4;3}; your_result = cellfun(@(a,b) [a ' ' num2str(b)],a,b,...

13 years ago | 0

Answered
systematic: Do not use global, don't use eval
In small programs it's not a problem. If you are the only one that will be ever using your code, it should not be a problem. It ...

13 years ago | 3

Answered
Returning which button was pressed.
f = figure(1); click_type=get(f,'SelectionType'); if strcmp(click_type,'normal') %right click %Do some stuff el...

13 years ago | 0

| accepted

Answered
How can I select all the nonzero elements of a matrix and give out a matrix?
your_mat = A(A~=0); And if you want a sparse matrix: your_mat = sparse(A);

13 years ago | 0

Answered
numerical stable triangulation method?
# No. Both are valid Delaunay triangulations. # None, unless you write it yourself. You could always try the file exchange, may...

13 years ago | 0

| accepted

Answered
Is there something wrong with the find function?
From the documentation on the colon operator: j:i:k is the same as [j,j+i,j+2i, ...,j+m*i] In your vector _0.2_ would b...

13 years ago | 1

| accepted

Answered
Conversion from uint8 to ascii to number
Somewhat convoluted, depends on whether you can use _sprintf()_ and _sscanf()_: your_ascii = [48 46 56 52]; your_asci...

13 years ago | 0

Answered
Coin toss game simulation.
num_toss = 10; %Toss the coin vec_toss = rand(num_toss,1) > 0.5; %Get the average: mean_vec = cumsum(vec_toss)./(1...

13 years ago | 0

| accepted

Answered
Correct plot in matlab
Try: plot(Shear(:,1),Shear(:,2)); If you give a matrix as an argument to _plot()_ it will draw each column as independ...

13 years ago | 0

Answered
how can store two power 1000 value in matlab.
<http://en.wikipedia.org/wiki/Integer_(computer_science) You can't.>

13 years ago | 0

Answered
How can I use an return value from function1 in function2 (different m.files)?
You need to pass returnval1 to fun2: function returnval1 = fun1(input1,input2,input3) %do your stuff function f...

13 years ago | 0

Answered
What can I do to large scale array?
There are two limiters: data type and addressable memory. The data type will affect how much memory is needed. It can be solved ...

13 years ago | 0

| accepted

Answered
How do I create a create 'for' loop to compute time, position, velocity and add to running sum?
Indexes in Matlab start with one, not zero. _which_ever_array(0)_ will return an error. In your example, you could, amongst oth...

13 years ago | 0

Answered
Draw uninterrupted lines on a plot with missing values
idx = ~any(isnan(y),1); plot(x(idx),y(idx)); Also, you could use _nanmean()_ to get the mean in the presence of NaN'...

13 years ago | 2

| accepted

Load more