Borrar filtros
Borrar filtros

problem is that when i run matlab code using F5

5 visualizaciones (últimos 30 días)
vipul utsav
vipul utsav el 15 de Feb. de 2013
clc
close all;
clear all;
n=0+(10*randn(400));
nn=imcrop(n,[0 0 16 16]);
std(nn(:))
I generate noise '0+10*randn' function,then i found std(:) of noisy image but problem is that when i run matlab code using F5 in matlab,every time std(:) is different(above code) 9.5163,10.5658,9.5044,9.40,10.41
so my question is that which value should taken of std(nn(:)) of above code.
  1 comentario
Jan
Jan el 15 de Feb. de 2013
Please take a look on your code again. Half of the lines perform a brute clearing of Matlab's currently parsed functions, the command window, the variables and open windows. This is neither useful nor does it help to solve the problem. See e.g. Answers: 22301

Iniciar sesión para comentar.

Respuestas (2)

Vishal Rane
Vishal Rane el 15 de Feb. de 2013
The command
randn(400)
generates a random 400*400 matrix every time. Hence the random result. Are you not expecting this ?
  2 comentarios
Walter Roberson
Walter Roberson el 15 de Feb. de 2013
Right. With larger matrices, the std() will vary less between runs, but they are going to be different.
randn() approaches a standard deviation of 1 as the number of trials approaches infinity.
vipul utsav
vipul utsav el 15 de Feb. de 2013
you are right and i know it.
but i want to take one particular value

Iniciar sesión para comentar.


Jan
Jan el 15 de Feb. de 2013
Editada: Jan el 15 de Feb. de 2013
It is not clear, what "one particular value" could be, when you add random noise. When you want to initialize the random number generator, such that RAND replies the same values in each run:
s = RandStream.create('mt19937ar', 'seed', 5489);
RandStream.setDefaultStream(s);
This is explained in the documentation, see doc rand.
  3 comentarios
Jan
Jan el 15 de Feb. de 2013
I cannot imagine what "I put value" means. I still do not understand, what you are looking for: You state, that the standard deviation of a random matrix varies from call to call, because the values replied by the random number generator vary - according to the definition of "random numbers". I've suggested to use a fixed seed, such that the random number generator is initialized by the same value in each run. Did you try to insert the suggested lines in your code and is your problem solved then? If not, please explain the difference between the results and your expectations.
Please, vipul, try to explain, what you actually want. Letting us guess it, wastes your and our time.
Image Analyst
Image Analyst el 15 de Feb. de 2013
I think for some reason he's thinking he should get exactly 10 out since he specified 10 as the stddev. However that doesn't agree with his response to Walter, where he indicated that he realized that the stddev will vary slightly. So, like you I have no idea what he wants and we need to see if he'll clarify.

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by