0

Hi I have a function ((4*pi*100./lambda).^2) and I need to plot for every value deviation which is done by randn() but it only plots function ((4*pi*100./lambda).^2).

c=3e8;

f=0.1e12:0.1e12:10e12;

lambda=c./f;

spread=((4*pi*100./lambda).^2);

y = spread + randn(size(f));

plot(y,(1:100))
Romano Zumbé
  • 7,893
  • 4
  • 33
  • 55
user3720192
  • 13
  • 1
  • 3

2 Answers2

0

You can use errorbar

    c=3e8;

    f=0.1e12:0.1e12:10e12;

    lamda=c./f;

    spread=((4*pi*100./lamda).^2);

    y = spread ;
    err_vals = randn(size(f))

    %plot(y,(1:100))
    errorbar(y,err_vals)
Marcin
  • 215,873
  • 14
  • 235
  • 294
  • http://www.mathworks.com/help/matlab/examples/fft-for-spectral-analysis.html but this should work whithout errorbar. – user3720192 Jun 09 '14 at 23:20
  • @user3720192 the spread values are of much higher order than the random noise you add, thus it is not visible in the plot. Make bigger noise, e.g. `randn(size(f))*10e13`. – Marcin Jun 09 '14 at 23:59
0

I did make it work. Yes size of random numbers was to small and two matrices had different sizes. Command used to find out matrices size is whos.

 c=3e8;

f=0.1e12:0.1e12:10e12;
 lamda=c./f;

 spread= ((4*pi*100./lamda).^2)

  abs = randi([20 35543e9],1,100)
 whos spread abs
     A = spread + abs
     y= 10*log(A)

     plot(f,y)
user3720192
  • 13
  • 1
  • 3