how to replace all negative values from an iddata with zero?

3 ビュー (過去 30 日間)
Gina  Cabas
Gina Cabas 2017 年 12 月 6 日
回答済み: Elizabeth Reese 2017 年 12 月 8 日
Hello Matlab community! I have an iddata with predicted values from an ARMAX model, for the analysis, I want to replace all negative values with zero, and then plot the result of measured vs predicted in the same graph, how can I do that? I tried to subtract the output values yp.y, been yp the iddata with the predicted values, and then set the negatives values to zero y(y<0)=0, and again construct the iddata yp1 = iddata(y,[],5,'TimeUnit','minutes) but then I realized the zero values are still there and the plot of measured vs predicted is done separately. so I wanna know if there is a way to replace the negative values with zero without extracting the output vector out of the iddata format. thanks

回答 (1 件)

Elizabeth Reese
Elizabeth Reese 2017 年 12 月 8 日
I was working based on the example here in the predict documentation.
This example creates a data iddata object of measured outputs and a yp iddata object of predicted outputs.
If I want to change the data inside the yp object, I can do that using:
yp.OutputData
So, to change all of the negatives values in yp to 0, I would do:
yp.OutputData(yp.OutputData < 0) = 0;
If you want to do this for data, you can as well. Then, I could plot the data and yp against each other using:
plot(data,yp);
legend('Estimation data','Predicted data');

カテゴリ

Help Center および File ExchangeNonlinear ARX Models についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by