Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- p = 4; % number of plots to be drawn
- k = 0;
- SNR = 0;
- for k=0:p-1
- SNR = SNR + 5; % start SNR
- % create monoexponential data (e.g. MSE)
- M0 = 500;
- T2 = 30e-3;
- Messpunkte=20;
- TE = linspace(5e-3,200e-3,Messpunkte); % create array of echo-times
- temp_signal=M0*exp(-TE/T2);
- temp_signal=awgn(temp_signal,SNR,'measured'); %add gaussian noise
- temp_signal(2:end)=temp_signal(2:end) + M0*exp(-TE(2:end)/T2)*0.2;
- TE=TE(2:end);
- temp_signal=temp_signal(2:end);
- % set up inequality set to find a constrained minimum of a scalar
- % function of several variables starting at an initial estimate
- AT2 = [-eye(2); eye(2)];
- bT2 = [-1e-12*ones(1,2) 10e3 1];
- initial=[1,1];
- fun = @(param) norm(temp_signal - (param(1)*exp(-TE/param(2))) );
- % constrained nonlinear optimization
- f_param = fmincon(fun, initial, AT2, bT2, [],[],[],[],[]);
- % show fitted parameters
- fitted_plot=f_param(1)*exp(-TE/f_param(2));
- subplot(1,p,k+1)
- plot(TE, temp_signal, 'Color',[0,0.7,0.9], 'LineWidth', 1); hold all
- plot(TE, fitted_plot, 'r', 'LineWidth', 1);
- title({'monoexp fit'; ['T_2=' num2str(f_param(2)) 's' ...
- ' (M_0=' num2str(f_param(1)) ')']})
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement