Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Interpolation code. How can I deal with a strange problem.

조회 수: 1 (최근 30일)
GEORGIOS BEKAS
GEORGIOS BEKAS 2020년 6월 14일
마감: MATLAB Answer Bot 2021년 8월 20일
Imagine that I want to express in a way that I will describe below, a number that falls into a possible range of values.
E.g. the worse value is 30 and the best is 2.
So 16 would be expressed as: 1*w1 + 0*w2.
And 3 would be expressed as: 1*w1 + 0.93*w2.
What is a general code for this pattern?
Is the following code correct?
function [w1 w2] = intrpolate(worse,best, given)
md = (worse+best)/2
if given >= md
int = (given-md)/(best - md)
w1 = 1
w2 = int
else
int = abs((given-md))/(worse - md)
w1 = int
w2 = 0
end
end

답변 (1개)

Matt J
Matt J 2020년 6월 14일
편집: Matt J 2020년 6월 14일
Looks like a simple, 2x2 linear equation system to me.
>> w=[1, 0;1,0.93]\[16;3]
w =
16.0000
-13.9785
  댓글 수: 2
GEORGIOS BEKAS
GEORGIOS BEKAS 2020년 6월 14일
this is not a generic code
Matt J
Matt J 2020년 6월 14일
편집: Matt J 2020년 6월 14일
Your problem description was no more generic... Are you saying the numbers 1, 0.93, 16 etc... could be different in the future? Well, it still seems obvious how you would generalize it, if so.

이 질문은 마감되었습니다.

제품


릴리스

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by