1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| data = {{3.0, 3.0, 1}, {3.0, 1.5, 2}, {3.0, 1.3, 2.2}, {3.7, 1.7, 2.2}, {3.0, 0.8, 3.3}, {3.8, 1.1, 3.3}, {4.5, 1.3, 3.3}, {3.5, 0.7, 4.7}, {4.8, 1, 4.7}, {4.8, 0.9, 5.1}, {4.3, 0.8, 5.1}};
(*提取电压=3.0V的数据并按电阻排序*) constantVoltageData = Select[data, sortedData = SortBy[constantVoltageData,
ListLinePlot[sortedData[[All, {3, 2}]], PlotMarkers -> Automatic, Frame -> True, FrameLabel -> {"电阻 (k\[CapitalOmega])", "电流 (mA)"}, PlotLabel -> "电压恒定(3.0V): 电阻\[UpArrow], 电流\[DownArrow]", FrameStyle -> Directive[Black, 12], GridLines -> Automatic, ImageSize -> 400] (*按电阻值分组*)groupedData = GatherBy[data, (*只保留有多个数据点的组*) multiPointGroups = Select[groupedData, Length[
ListLinePlot[ PlotMarkers -> Automatic, Frame -> True, FrameLabel -> {"电压 (V)", "电流 (mA)"}, PlotLabel -> "电阻恒定: 电压\[UpArrow], 电流\[UpArrow]", FrameStyle -> Directive[Black, 12], PlotLegends -> ("R = " <> ToString[ " k\[CapitalOmega]" & /@ multiPointGroups), GridLines -> Automatic, ImageSize -> 400] constantVoltageData = {{3.0, 3.0, 1}, {3.0, 1.5, 2}, {3.0, 1.3, 2.2}, {3.0, 0.8, 3.3}}; TableForm[constantVoltageData, TableHeadings -> {None, {"电压(V)", "电流(mA)", "电阻(k\[CapitalOmega])"}}] (*绘制实验数据点*) dataPoints = ListPlot[constantVoltageData[[All, {3, 2}]], PlotStyle -> {Red, PointSize[0.02]}, Frame -> True, FrameLabel -> {"电阻R (k\[CapitalOmega])", "电流I (mA)"}, GridLines -> Automatic, PlotRange -> All];
(*绘制理论函数 I=3.0/R*) theoreticalPlot = Plot[3.0/r, {r, 0.5, 5}, PlotStyle -> Blue, PlotLegends -> {"I = 3.0/R"}];
(*合并图形*) Show[theoreticalPlot, dataPoints, PlotLabel -> "函数关系: 电流I = 电压V / 电阻R"] V = 3.0; predictedI = V/5 (*输出:0.6 mA*) Manipulate[ Plot[V/r, {r, 1, 10}, Frame -> True, FrameLabel -> {"R (k\[CapitalOmega])", "I (mA)"}], {V, 1, 10, 0.1}, Initialization :> (V = 3.0)] TableForm[Table[{r, 3.0/r}, {r, 1, 5, 0.5}], TableHeadings -> {None, {"R (k\[CapitalOmega])", "I (mA)"}}]
|