# Manipulating multiple datasets at once and exporting properly

1 view (last 30 days)
Julia de Lange on 10 Jan 2019
Answered: halil on 19 Aug 2019
I have a dataset that I am trying to manipulate. Basically, I have 28 excel files, all with 10 columns of data. I'd like to read in all excel files, perform the same operations on them, and write to a file the data curves for each operation. I'd also like figures displaying the data and associated curves.
These are the opeartions I need to perform:
• Perform an operation on column C and D: (102/((C1/D1)-1)) - resistance (R)
• Perform an operation on column G: G/0.002 - pressure (P)
• Find index start and finish of loading portion, when C rises above threshold (start), and then drops down and rises again to same threshold (finish)
• FInd index of minimum C
• Calculate the average resistance during loading (using the time markers from the voltage-time curve) Average Change in Resistance (AR) = (Rstart– Rmin voltage)/(Duration of impact)
• Find a curve of formula y=a*x^b+c (where y = P, and x=R) from index start to index min voltage of pressure versus resistance, for each of the 28 files
• Show graphs of curves
• Output a, b, c variables and Rstart, Rmin, R fin, AR for each curve to .txt file
Can anyone please tell me where to start? I'd like some guidance as for how to manipulate so much data at once, and how to output the data correctly. This is the code I have so far:
folder = 'C:\Users\julia\Desktop\jan2019';
filetype='*.xls';
fsensors=fullfile(folder,filetype);
d=dir(fsensors);
fw= fopen('C:\Users\julia\Documents\MATLAB\jan_calibrations\calibrationcurves.txt' , 'w' );
for k = 1:numel(d); %length of source files
start=1;
close all ;
vel = d(:,1);
accel = d(:,2);
ext_volt = d(:,3);
sens_volt = d(:,4);
lc_fz = d(:,7);
voltage = (ext_v/sens_v);
pressure = (lc_fz)/(.04*.05); %for sens8
for i=1:length(voltage)
resistance(i)=(102/(1/voltage(i)-1));
if pressure(i)>.5E4 %4E4
start(j)=i;
j=j+1;
end
end
x=resistance(start(1):end);
y=pressure(start(1):end);
figure('Position' , [50, 50, 1049, 895]);
s=plot(resistance,pressure,'linewidth' , 3 , 'color' , 'r' );
xlim([0,200])
xlabel('Resistance (\Omega)' , 'fontsize' , fs, 'FontName' , 'Times' );
ylabel ('Pressure (Pa)' ,'fontsize' , fs, 'FontName' , 'Times' );
ylim([0, 3.5E5])
set(gca, 'fontsize' , fs, 'FontName' , 'Times' )
f=ezfit(x,y,'((a*x^b)+c);a=6E6; b=-1.5; c=20000' ); %(a+(a*x))*exp(-b*x); a=1200')'');
showfit(f, 'dispeqboxmode' , 'off' , 'boxlocation' , [0.60 0.81 0.1 0.1], 'fitlinestyle' , '--' ,'fitcolor' , 'k' , 'fitlinewidth' , 3);
legend([s], 'Sensor', '- Fit', 'fontsize', fs, 'FontName', 'Times')
fprintf(fw,'%d %d %d %d %d\n' ,f.m(1), f.m(2), f.m(3), f.r, area); %writes variables as integers, in that order
end

halil on 19 Aug 2019
Hi
Sorry cant help but I have the same question as the one you made sometimes ago. did you get any reply. my email khalil.khalili@hest.ethz.ch please get back to me.