How do I plot an interval with this?

Hi, guys,
w = linspace(1,2,100);
p = dval(x,as,w);
plot(w,p)
I want to plot an interval by using this function.
But I got nonconformant arguments, how do i get this to work correctly?
I would appreciate it if someone could help me.
function s = dval(x, a, v)
n = length(a);
s = a(n);
for i = n-1:-1:1
s = s *(v-x(i))+a(i); % got errors here
end

回答 (1 件)

VBBV
VBBV 2021 年 5 月 1 日

1 投票

%if true
function S = dval(x, a, v)
n = length(a);
s = a(n);
for i = n-1:-1:1
s = s.*(v-x(i))+a(i); % got errors here
end
Try this

3 件のコメント

Charlotte Smith
Charlotte Smith 2021 年 5 月 1 日
Thank you very much! It works!
Image Analyst
Image Analyst 2021 年 5 月 1 日
Charlotte, can you then please "Accept this link" to give @VBBV reputation points for his efforts.
VBBV
VBBV 2021 年 5 月 1 日
編集済み: VBBV 2021 年 5 月 2 日
Thank you @Image Analyst

サインインしてコメントする。

カテゴリ

質問済み:

2021 年 5 月 1 日

編集済み:

2021 年 5 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by