How to print a line of text with multiple variables
Hello.
I am trying to print out a statement that says something like "The confidence interval for the gauge pressure measured at 10 psi is (9.5048 ± 1.5608) psi." using the values below.
%Initial Uncalibrated Meas.
p_analog_uncal = [20 40 60 80 100 120];
dV_avg_uncal = [1.246378 1.500449 1.763329 2.015415 2.292663 2.567350];
std_dev_uncal = [0.000867 0.000879 0.000885 0.000958 0.000938 0.000956 0.000908];
gain = 76.2710;
offset = 0.9812;
N = 10000;
%Calibrated Meas.
p_analog_cal = [10 30 50 70 90 110];
p_gage = [9.504823 30.232948 50.373663 70.164445 90.059363 109.971692];
std_dev_cal = [0.067066 0.069131 0.067868 0.068035 0.073534 0.071066];
%Calibration Unc
p_pred = (gain.*dV_avg_uncal) – (gain*offset);
p_residual = (p_pred – p_analog_uncal).^2;
s = sum(p_residual, "all");
sy = sqrt(s/4);
t =1.95996;
uc = t*sy;
%First Order Unc
u1 = std_dev_cal./(sqrt(N – 1));
%Overall Uncertainty
uo = sqrt((u1.^2) + (uc^2));
I have tried using:
fprintf(‘The confidence interval for the gauge pressure measured at %d psi is (%7.4f ± %5.4f) psi.n’, p_analog_cal, p_gage, uo)
but it spits out lines that look like this:
The confidence interval for the gauge pressure measured at 10 psi is (30.0000 ± 50.0000) psi.
The confidence interval for the gauge pressure measured at 70 psi is (90.0000 ± 110.0000) psi.
The confidence interval for the gauge pressure measured at 9.504823e+00 psi is (30.2329 ± 50.3737) psi.
How can I fix this so that each pressure corresponds with its confidence interval?Hello.
I am trying to print out a statement that says something like "The confidence interval for the gauge pressure measured at 10 psi is (9.5048 ± 1.5608) psi." using the values below.
%Initial Uncalibrated Meas.
p_analog_uncal = [20 40 60 80 100 120];
dV_avg_uncal = [1.246378 1.500449 1.763329 2.015415 2.292663 2.567350];
std_dev_uncal = [0.000867 0.000879 0.000885 0.000958 0.000938 0.000956 0.000908];
gain = 76.2710;
offset = 0.9812;
N = 10000;
%Calibrated Meas.
p_analog_cal = [10 30 50 70 90 110];
p_gage = [9.504823 30.232948 50.373663 70.164445 90.059363 109.971692];
std_dev_cal = [0.067066 0.069131 0.067868 0.068035 0.073534 0.071066];
%Calibration Unc
p_pred = (gain.*dV_avg_uncal) – (gain*offset);
p_residual = (p_pred – p_analog_uncal).^2;
s = sum(p_residual, "all");
sy = sqrt(s/4);
t =1.95996;
uc = t*sy;
%First Order Unc
u1 = std_dev_cal./(sqrt(N – 1));
%Overall Uncertainty
uo = sqrt((u1.^2) + (uc^2));
I have tried using:
fprintf(‘The confidence interval for the gauge pressure measured at %d psi is (%7.4f ± %5.4f) psi.n’, p_analog_cal, p_gage, uo)
but it spits out lines that look like this:
The confidence interval for the gauge pressure measured at 10 psi is (30.0000 ± 50.0000) psi.
The confidence interval for the gauge pressure measured at 70 psi is (90.0000 ± 110.0000) psi.
The confidence interval for the gauge pressure measured at 9.504823e+00 psi is (30.2329 ± 50.3737) psi.
How can I fix this so that each pressure corresponds with its confidence interval? Hello.
I am trying to print out a statement that says something like "The confidence interval for the gauge pressure measured at 10 psi is (9.5048 ± 1.5608) psi." using the values below.
%Initial Uncalibrated Meas.
p_analog_uncal = [20 40 60 80 100 120];
dV_avg_uncal = [1.246378 1.500449 1.763329 2.015415 2.292663 2.567350];
std_dev_uncal = [0.000867 0.000879 0.000885 0.000958 0.000938 0.000956 0.000908];
gain = 76.2710;
offset = 0.9812;
N = 10000;
%Calibrated Meas.
p_analog_cal = [10 30 50 70 90 110];
p_gage = [9.504823 30.232948 50.373663 70.164445 90.059363 109.971692];
std_dev_cal = [0.067066 0.069131 0.067868 0.068035 0.073534 0.071066];
%Calibration Unc
p_pred = (gain.*dV_avg_uncal) – (gain*offset);
p_residual = (p_pred – p_analog_uncal).^2;
s = sum(p_residual, "all");
sy = sqrt(s/4);
t =1.95996;
uc = t*sy;
%First Order Unc
u1 = std_dev_cal./(sqrt(N – 1));
%Overall Uncertainty
uo = sqrt((u1.^2) + (uc^2));
I have tried using:
fprintf(‘The confidence interval for the gauge pressure measured at %d psi is (%7.4f ± %5.4f) psi.n’, p_analog_cal, p_gage, uo)
but it spits out lines that look like this:
The confidence interval for the gauge pressure measured at 10 psi is (30.0000 ± 50.0000) psi.
The confidence interval for the gauge pressure measured at 70 psi is (90.0000 ± 110.0000) psi.
The confidence interval for the gauge pressure measured at 9.504823e+00 psi is (30.2329 ± 50.3737) psi.
How can I fix this so that each pressure corresponds with its confidence interval? fprinf, sprintf, %f, %d MATLAB Answers — New Questions









