代码解释plot(1:length(t_test),t_test,'r-*',1:length(t_test),predict_2,'b:o')
时间: 2024-05-29 16:10:02 浏览: 16
这段代码使用plot函数在同一个坐标系中绘制两条曲线。第一个参数是x轴数据,使用1:length(t_test)生成了一个长度为t_test的长度的整数向量作为x轴数据。第二个参数是y轴数据,t_test是一个向量,用作第二个参数。第三个参数'r-*'是用于绘制第一条曲线的选项,其中'r-'表示红色实线,'*'表示用星号标记数据点。第四个参数1:length(t_test)是用于第二条曲线的x轴数据,第五个参数predict_2是用于第二条曲线的y轴数据,用'b:o'选项绘制,其中'b-'表示蓝色实线,'o'表示用圆圈标记数据点。
相关问题
错误使用 plot 向量长度必须相同。 出错 main (line 68) plot(1:length(test_labe
这个错误很可能是因为你的 `test_label` 向量的长度和你要画图的另一个向量的长度不一致。请检查一下这两个向量的长度是否相同,如果不同,需要将它们的长度调整为相同的长度才能成功画出图形。你可以尝试使用 `length` 函数获取两个向量的长度,然后进行比较,看看哪个向量的长度与另一个不一致,从而找到问题所在。
解读一下 figure subplot(211) plot(1:length(T_train),T_train, 'r-', 1:length(T_sim1),T_sim1, 'b-.', 'LineWidth', 1) legend('实际值', 'BP预测值') xlabel('训练集') ylabel('负荷(kW)') axis tight string = {['BP 训练集:(RMSE= ' num2str(RMSE1) ' MAPE = ' num2str(MAPE1) ')']}; title(string) subplot(212) bar(err1) xlabel('训练集') ylabel('Error') axis tight figure subplot(211) plot(1:length(T_test),T_test,'r-', 1:length(T_sim2),T_sim2, 'b-.', 'LineWidth', 1) legend('实际值', 'BP预测值') xlabel('测试集') ylabel('负荷(kW)') axis tight string = {['BP 测试集:(RMSE= ' num2str(RMSE2) ' MAPE = ' num2str(MAPE2) ')']}; title(string) subplot(212) bar(err2) xlabel('训练集') ylabel('Error') axis tight
这段代码是用于绘制两个图形的,每个图形都有两个子图。第一个图形的第一个子图使用subplot(211)函数,用于绘制训练集的实际负载值和BP神经网络的预测负载值,分别使用红色实线和蓝色点划线进行绘制。legend函数用于添加图例,xlabel和ylabel函数分别用于添加x轴和y轴标签,axis tight函数则是调整坐标轴范围。title函数用于添加子图的标题,其中包含了RMSE和MAPE两个指标的值。第二个子图使用bar函数绘制训练集的误差,用于观察BP神经网络训练的效果。
第一个图形的第二个子图使用subplot(212)函数,用于绘制测试集的实际负载值和BP神经网络的预测负载值,同样使用红色实线和蓝色点划线进行绘制。legend、xlabel、ylabel、axis tight和title函数的作用与第一个子图相同。第二个子图使用bar函数绘制测试集的误差,用于评估BP神经网络的预测效果。
相关推荐
![m](https://img-home.csdnimg.cn/images/20210720083646.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![application/x-zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)