Yahoo奇摩知識+ 將於 2021 年 5 月 4 日 (美國東部時間) 終止服務。自 2021 年 4 月 20 日 (美國東部時間) 起，Yahoo奇摩知識+ 網站將會轉為唯讀模式。其他 Yahoo奇摩產品與服務或您的 Yahoo奇摩帳號都不會受影響。如需關於 Yahoo奇摩知識+ 停止服務以及下載您個人資料的資訊，請參閱說明網頁。

Ed 發問時間： 電腦與網際網路程式設計 · 9 年前

# MATLAB 問題 POLYNOMIAL

The following data represents the volume of ice needed to adequately chill a given volume of hot water. Write a Matlab script to fit a first order to polynomial to the dataset described by volume of water vs. volume of ice. Plot your dataset as points, and your fitted equation as a solid line in the domain 0 ≤ Vwater ≤ 5. Use a legend to identify the data points and the fitted equation. Use your equation to find and print the volume of ice needed to chill 1 cup of hot water.

Volume of Hot Water (cups) 2.6 2.9 3.2 3.5 3.8 4.1

Volume of Ice (cups) 2.60 2.70 2.75 2.87 2.97 3.50

### 1 個解答

• 9 年前
最佳解答

clc

clear

%Problem 4

%Input all given data

time=[0 550 2230 3488];

temp=[145 130 105 93];

%Plot the graph

subplot(2,1,1)

plot(time,temp,'d','linewidth',1.8)

hold on

%Convert 20 minutes to second

T1=20*60;

T2=interp1(time,temp,T1,'spline');

%Print the solution

fprintf('The Coffee Temperature After 20 Minutes: %.2f F\n',T2)

%Range is from 0 to 3500 second

tvec=[0:3500];

tempvec=interp1(time,temp,tvec,'spline');

%Plot the graph

plot(tvec,tempvec,'linewidth',1.8)

%Title, x and y label

title('COFFEE COOLING CURVE')

xlabel('time(s)')

ylabel('Temperature(F)')

grid on

legend('DATA POINTS','Spline Interpolation')

參考資料： 自己