How can I get the set number from a set?

조회 수: 2 (최근 30일)
Alex Wheeler
Alex Wheeler 2021년 3월 4일
댓글: Stephen23 2021년 3월 4일
I have written the following code, I want to determine which of the following protein_mass's is the lowest, how can I go about that?
disp('IMPORTANT: Before you input any numbers please remember to type the inputs in chronological order of the samples to have the best chance possible of having correct data')
volume = input('Enter the volumes of the sample (in μL) with [] surrounding them: ');
concentration = input('Enter the total protein concentration (in μg/mL) with [] surrounding them: ');
mass_fraction = input('Enter the mass fraction of Gal-7hFc (mass Gal-7hFc/total mass protein) with [] surrounding them: ');
protein_mass1 = (volume(1)/1000) * concentration(1); %mass in μg
protein_mass2 = (volume(2)/1000) * concentration(2); %mass in μg
protein_mass3 = (volume(3)/1000) * concentration(3); %mass in μg
protein_mass4 = (volume(4)/1000) * concentration(4); %mass in μg
Gal_mass1 = protein_mass1 * mass_fraction(1);
Gal_mass2 = protein_mass2 * mass_fraction(2);
Gal_mass3 = protein_mass3 * mass_fraction(3);
Gal_mass4 = protein_mass4 * mass_fraction(4);
protein_masses = [protein_mass1 protein_mass2 protein_mass3 protein_mass4];
min(protein_masses);
  댓글 수: 1
Stephen23
Stephen23 2021년 3월 4일
"I want to determine which of the following protein_mass's is the lowest, how can I go about that?"
Answer: use the second output from min.
Tip: avoid numbering variable names like that. Effective use of MATLAB means keeping data together in vectors/matrices/arrays and applying operations to the entire array at once. This is often simpler and more efficient:

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by