Info
此问题已关闭。 请重新打开它进行编辑或回答。
Giving input x from different matrix?
1 次查看(过去 30 天)
显示 更早的评论
For computation of area the value of y1,y2 and y3 are coming from three different same dimension matrix and so I want to compute area of using this code for same matrix dimension as y1, y2 and y3?
x=[7.8 8.25 8.55];
y=[0.96 0.99 0.94];
p=polyfit(x,y,2);
t=linspace(x(1),x(3));
yhat=polyval(p,t);
a1=trapz(t,yhat);
How can I improve code for all 3*3 matrix of given y1,y2 and y3, result will be area a1 of 3*3 matrix.
1 个评论
Roger Stafford
2013-5-27
I already gave you a formula for that identical question two weeks ago which avoids the 'trapz' operation. In that formula all you have to do is substitute x(1) for x1, x(2) for x2, and x(3) for x3. Then if y is your 3 x 3 array, substitute y(:,1) for y1, y(:,2) for y2, and y(:,3) for y3. What is so difficult about that?
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!