d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Matlab Create An Output File > Yes Please =)
Add Reply New Topic New Poll
Member
Posts: 17,765
Joined: Jul 19 2009
Gold: 16,694.00
Nov 23 2015 07:43am
Hello guys!

I am working as a physicist with matlab.

I am not sure if it is necessary, but here is the code I use:

Code


clear;
clc;

autofit_start_wl = 640;
autofit_stop_wl = 765;

[wl, spectra] = my_importfile_spectra('\\file\e24\Projects\FinleyLab\_IQPGroup\_plasmon WG\Samples\S2\S2.8\2015-10-21 Detection Scans\19-Spectral Piezo Scan along WG1 HeNe 1.2mW -5...1..5 .5s .1_spectra.dat', 3, 1029);
autofit_start = find(wl <= autofit_stop_wl, 1);
autofit_stop = find(wl >= autofit_start_wl, 1, 'last');
fitdata = fitAllSpectra(wl(autofit_start:autofit_stop), ...
spectra(autofit_start:autofit_stop, :), [800 1500 1000 2 4 745 760]);
fit_backgrounds = fitdata(:, 3);

laser_center_wl = zeros(size(spectra, 2), 1);
laser_int = zeros(size(spectra, 2), 1);
laser_start = size(spectra, 1);
laser_wl = wl(autofit_stop:laser_start);
laser_spectra = spectra(autofit_stop:laser_start, :);
for i=1:size(laser_spectra, 2)
spectrum = laser_spectra(:, i) - fit_backgrounds(i);
laser_int(i) = sum(sum(spectrum));
laser_center_wl(i) = 1/laser_int(i) * laser_wl' * spectrum;
end
clear i spectrum laser_wl laser_start laser_spectra autofit_*

plotend = numel(laser_int);

scatter(1:plotend,fitdata(:,8))




What is this code doing?

Basically it about a double-gaussian fit of a spectrum, but who cares^^


My "needs"

This code creates several variables. I need a few of them being written in a .dat or .txt file including a description of what they are, so that I can import them into origin for further analysis.
Basically I need in one textfile:
fitdata - a 101x8 double
laser_int - a 101x1 double
laser_center_wl - a 101x1 double

I just started using matlab and was used to seperatly safe those values in a .dat file via matlab itself, but this gets really annoying if you have alot of data!

thanks in advance
Member
Posts: 4,572
Joined: Jun 28 2006
Gold: 1,376.49
Member
Posts: 2,231
Joined: Sep 10 2015
Gold: 11,168.81
Nov 23 2015 01:01pm
keke matlub lel
Member
Posts: 4,572
Joined: Jun 28 2006
Gold: 1,376.49
Nov 23 2015 01:53pm
Also might want to use Maple instead of Matlab or use both to validate your calculations.
I've almost got fucked once by rounding in Matlab, it was showing two really close roots as the same.
Member
Posts: 17,765
Joined: Jul 19 2009
Gold: 16,694.00
Nov 23 2015 02:29pm
Quote (Cyberbeni @ Nov 23 2015 08:24pm)


Ye google is my friend, got it now :D

Thanks man =)
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll