Storing data from while loop into an array

조회 수: 8 (최근 30일)
c_def
c_def 2016년 6월 7일
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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Medical Physics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by