How to sum the intervals in matlab
조회 수: 2 (최근 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
댓글 수: 0
채택된 답변
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
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 Center 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!