Advertisement
Guest User

Kein Muesli mehr da

a guest
May 24th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. p = 4; % number of plots to be drawn
  2. k = 0;
  3. SNR = 0;
  4.  
  5. for k=0:p-1
  6. SNR = SNR + 5; % start SNR
  7. % create monoexponential data (e.g. MSE)
  8. M0 = 500;
  9. T2 = 30e-3;
  10. Messpunkte=20;
  11. TE = linspace(5e-3,200e-3,Messpunkte); % create array of echo-times
  12. temp_signal=M0*exp(-TE/T2);
  13. temp_signal=awgn(temp_signal,SNR,'measured'); %add gaussian noise
  14. temp_signal(2:end)=temp_signal(2:end) + M0*exp(-TE(2:end)/T2)*0.2;
  15. TE=TE(2:end);
  16. temp_signal=temp_signal(2:end);
  17. % set up inequality set to find a constrained minimum of a scalar
  18. % function of several variables starting at an initial estimate
  19. AT2 = [-eye(2); eye(2)];
  20. bT2 = [-1e-12*ones(1,2) 10e3 1];
  21. initial=[1,1];
  22. fun = @(param) norm(temp_signal - (param(1)*exp(-TE/param(2))) );
  23. % constrained nonlinear optimization
  24. f_param = fmincon(fun, initial, AT2, bT2, [],[],[],[],[]);
  25. % show fitted parameters
  26. fitted_plot=f_param(1)*exp(-TE/f_param(2));
  27. subplot(1,p,k+1)
  28. plot(TE, temp_signal, 'Color',[0,0.7,0.9], 'LineWidth', 1); hold all
  29. plot(TE, fitted_plot, 'r', 'LineWidth', 1);
  30. title({'monoexp fit'; ['T_2=' num2str(f_param(2)) 's' ...
  31. ' (M_0=' num2str(f_param(1)) ')']})
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement