Exemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            int numeroPontos = int.Parse(txtNumeroPontos.Text);

            float[] vetorDados = new float[3];

            for (int i = 0; i < numeroPontos; i++)
            {
                vetorDados[0] = Convert.ToSingle(tabelaFinal.Rows[i].Cells[2].Value);
                vetorDados[1] = Convert.ToSingle(tabelaFinal.Rows[i].Cells[3].Value);
                vetorDados[2] = Convert.ToSingle(tabelaFinal.Rows[i].Cells[4].Value);

                double media        = Calculos.Media(vetorDados);
                double erro         = media - Convert.ToSingle(tabelaFinal.Rows[i].Cells[1].Value);
                double desvioPadrao = Calculos.DesvPad(vetorDados);
                double u1           = Calculos.IncertezaA(vetorDados, vetorDados.Length);
                double u2           = double.Parse(txtIncerteza2.Text);
                double u3           = double.Parse(txtIncerteza3.Text);
                double uCombinada   = Calculos.UCombinada(u1, u2, u3);
                double veff         = Calculos.GrausLiberdade(uCombinada, u1, vetorDados.Length);
                double fatorK       = Calculos.FatorK(veff);
                double uFinal       = Calculos.UFinal(fatorK, uCombinada);

                tabelaFinal.Rows[i].Cells[5].Value = Math.Round(media, 4);
                tabelaFinal.Rows[i].Cells[6].Value = Math.Round(erro, 4);
                tabelaFinal.Rows[i].Cells[7].Value = Math.Round(uFinal, 4);
                tabelaFinal.Rows[i].Cells[8].Value = Math.Round(fatorK, 3);
            }
        }
Exemplo n.º 2
0
        private void btnCalcula_Click(object sender, EventArgs e)
        {
            float[] vetorDados = new float[3];

            try
            {
                vetorDados[0] = float.Parse(txtLeitura1.Text);
                vetorDados[1] = float.Parse(txtLeitura2.Text);
                vetorDados[2] = float.Parse(txtLeitura3.Text);
            }
            catch
            {
            }

            double media       = Calculos.Media(vetorDados);
            double devioPadrao = Calculos.DesvPad(vetorDados);
            double u1          = Calculos.IncertezaA(vetorDados, vetorDados.Length);
            double u2          = double.Parse(txtIncerteza2.Text);
            double u3          = double.Parse(txtIncerteza3.Text);
            double uCombinada  = Calculos.UCombinada(u1, u2, u3);
            double veff        = Calculos.GrausLiberdade(uCombinada, u1, vetorDados.Length);
            double fatorK      = Calculos.FatorK(veff);
            double uFinal      = Calculos.UFinal(fatorK, uCombinada);

            txtMedia.Text          = media.ToString();
            txtDesvPad.Text        = devioPadrao.ToString();
            txtIncerteza1.Text     = u1.ToString();
            txtIncerteza4.Text     = uCombinada.ToString();
            txtVeff.Text           = veff.ToString();
            txtK.Text              = fatorK.ToString();
            txtIncertezaFinal.Text = uFinal.ToString();
        }
Exemplo n.º 3
0
        public static double IncertezaA(float[] vetor, int numeroMedidas)
        {
            double U = Calculos.DesvPad(vetor) / Math.Sqrt(Convert.ToDouble(numeroMedidas));

            return(U);
        }