How to sum the intervals in matlab

4 次查看(过去 30 天)
Hi
I am struggling in writing the codes, that could generate the new value automatically. Grateful for any help
My scenario is as follows:
value Error interval interval no. new value
1000 0.5 [0,1] 3 1000*(1+(( 0+ 1)/2)/100)=1005
800 -1.7 [-2,-1] 1 800*(1+((-2+-1)/2)/100)= 788
.....
here the interval no., say we have 4, we have a list of errors that fall within these intervals
1 [-2, -1] 2 [-1, 0] 3 [0,1] 4[1,2]
my codes so far
v = [1000 800 2000 950 1500]
er = [0.5 -1.7 1.85 -0.25 0.8]
inter1 = [0; -2; 1; -1; 0]
inter2 = [1; -1; 2,; 0; 1]
cal = (1+((inter1+inter2)/2)/100)
nv = cal*v
the output is wrong
this method would be tedious for a many values.
Any help in this matter is highly appreciated.
Many thanks

采纳的回答

Bruno Luong
Bruno Luong 2019-9-11
I have no idea what is the purpose and what is the problem, juste point out you might try
nv = cal.*v.'

更多回答(1 个)

dpb
dpb 2019-9-11
v=[1000;800]; err=[0.5;-1.7]; intvl=[0 1;-2 -1]; intvN=[3;1];
newv=v.*[1+mean(intvl,2)/100];
Above yields
>> newv
newv =
1.0e+03 *
1.0050
0.7880
>>

类别

Help CenterFile Exchange 中查找有关 Data Type Identification 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by