Int gives wrong(?) answer

function [ y ] = fn2( x, t )
t=0:0.001:1;
x=2*t;
plot(t,x,'k');
xlabel('t');
ylabel('2t')
syms x
%int(x,[0,1])
a = 1/2 * 1 * 2
y=int(x, 0, 1)
end
It keeps giving me y = 1/2, when it should be the same as a (Answer should be 1)
What am I doing wrong here?

回答 (2 件)

Walter Roberson
Walter Roberson 2019 年 4 月 22 日

0 投票

Not 1/2 * x * 2: it is 1/2 * x^2
madhan ravi
madhan ravi 2019 年 4 月 22 日

0 投票

int(x,0,1)
=> x^2/2 as Limits
1^2/2-0/2 => 1/2 % I don‘t see any mistakes ??

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

製品

リリース

R2017a

タグ

質問済み:

2019 年 4 月 22 日

回答済み:

2019 年 4 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by