Clear Filters
Clear Filters

Storing data from while loop into an array

1 view (last 30 days)
c_def
c_def on 7 Jun 2016
I'm still new to MatLab and have had some success writing code for my work, but need to store the data from a 'while' loop to an array that can then be exported to an Excel file. The current code just displays each value of PbC with the corresponding 'f'. I'd like to put it to export with two columns, with one column being 'f' and the other being the output of the variable PbC.
ratioA=input('Enter isotope ratio 1 of magma A: ');
PbA=input('Enter elemental ppm 1 of magma A: ');
%Magma B
ratioB=input('Enter isotope ratio 1 of Magma B: ');
PbB=input('Enter elemental ppm 1 of magma B ');
f=0;
while f<=0.09
f=f+0.01;
PbC= ((f*PbA*ratioA)+((1-f)*ratioB*PbB))/((f*PbA)+((1-f)*PbB));
Mix=[f; PbC];
end
% Mixing step of .1-1
while f<=0.99
f=f+0.1;
PbC= ((f*PbA*ratioA)+((1-f)*ratioB*PbB))/((f*PbA)+((1-f)*PbB));
Mix=[f; PbC];
end

Answers (0)

Categories

Find more on Data Import from MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!