Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SKO = 0.4;
- thSKO = 3 * 0.4;
- exval = 50;
- inimeas = normrnd(exval, SKO, [1000,1]);
- measurment_redux = count_error(inimeas);
- meas1 = count_error(inimeas);
- meas2 = count_error(inimeas);
- meas3 = count_error(inimeas);
- make_struct(inimeas)
- make_struct(measurment_redux)
- make_struct(meas1)
- make_struct(meas2)
- make_struct(meas3)
- draw_graph(inimeas, 'Resistors resistance graph (source), Ohm', 1);
- draw_graph(measurment_redux, 'Resistors resistance graph with defective resistors removed (source), Ohm', 2);
- draw_graph(meas1, 'Measuring the resistance of resistors 1, Ohm', 3);
- draw_graph(meas2, 'Measuring the resistance of resistors 1, Ohm', 4);
- draw_graph(meas3, 'Measuring the resistance of resistors 1, Ohm', 5);
- function result = count_error(arr)
- len = length(arr);
- exval = 50;
- result = zeros([len, 1]);
- for i = 1:len
- random_factor = rand() * 0.005;
- result(i) = arr(i) + random_factor * arr(i);
- if(result(i) > exval * 1.01 || result(i) < exval * 0.99)
- result(i) = exval;
- continue;
- end
- end
- end
- function draw_graph(arr, subgraph_title, number_in_graph)
- thSKO = 3 * 0.4;
- exval = 50;
- title(subgraph_title);
- subplot(5, 1, number_in_graph);
- histogram(arr);
- axis([exval - thSKO exval + thSKO 0 110]);
- end
- function result = make_struct(arr)
- result.distr = arr;
- result.std = std(arr);
- result.var = var(arr);
- result.mean = mean(arr);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement