Hello,
after I have run my simulation I obtaind these variables in my workspace and I would like to save them on excel.
Does someone knows a code that I can use? since they are many variables in an array type, but I haven't found yet a code that does wokr for me.
I would like to save product, TIS, error and error2
thanks in advanced

1 件のコメント

KSSV
KSSV 2020 年 7 月 22 日
You can save them into .mat file. REad about save.

サインインしてコメントする。

 採用された回答

Fangjun Jiang
Fangjun Jiang 2020 年 7 月 22 日

0 投票

xlswrite('MyFile.xlsx',[product, TIS, error, error2])

9 件のコメント

rough93
rough93 2020 年 7 月 22 日
Does this write each array to a different sheet?
Ilaria Shireen Sestili
Ilaria Shireen Sestili 2020 年 7 月 22 日
it gives me error saying that product is an unrecognized variable. Do you know why I am not able to access these variables? because this is a recurrent problem, whenever I try to call one of them it gives me the same error.
thanks to all of you!
Fangjun Jiang
Fangjun Jiang 2020 年 7 月 22 日
just type "product" in MATLAB Command Window to make sure they exist in workspace first.
Ilaria Shireen Sestili
Ilaria Shireen Sestili 2020 年 7 月 22 日
yeah actually it says it doesn't exist, do you happen to know what may be the problem?
Ilaria Shireen Sestili
Ilaria Shireen Sestili 2020 年 7 月 22 日
here is how I am saving them during the simulation.
Thanks a lot
Fangjun Jiang
Fangjun Jiang 2020 年 7 月 22 日
It is inside the struct "out".
In Simulink model, press Ctrl+E, Data Import/Export, un-check "single simulation output"
Ilaria Shireen Sestili
Ilaria Shireen Sestili 2020 年 7 月 22 日
although I can visualize them if I write out.TIS for example
Ilaria Shireen Sestili
Ilaria Shireen Sestili 2020 年 7 月 22 日
thank you so much!!!
Ilaria Shireen Sestili
Ilaria Shireen Sestili 2020 年 7 月 22 日
it works perfectly

サインインしてコメントする。

その他の回答 (1 件)

rough93
rough93 2020 年 7 月 22 日
編集済み: rough93 2020 年 7 月 22 日

0 投票

First, let's convert your data to tables:
product_table = array2table(product);
TIS_table = array2table(TIS);
error_table = array2table(error);
error2_table = array2table(error2);
then, you can specify the filename you want:
filename = 'your_filename.xlsx';
and write each table to your file on a different sheet:
writetable(product_table,filename,'Sheet',1)
writetable(TIS_table,filename,'Sheet',2)
writetable(error_table,filename,'Sheet',3)
writetable(error2_table,filename,'Sheet',4)

3 件のコメント

Ilaria Shireen Sestili
Ilaria Shireen Sestili 2020 年 7 月 22 日
it gives me error saying that product is an unrecognized variable. Do you know why I am not able to access these variables? because this is a recurrent problem, whenever I try to call one of them it gives me the same error.
it seems that these variables are properties of the output
thanks to all of you
rough93
rough93 2020 年 7 月 22 日
Follow Fangjun's suggestion and let us know the answer, this code should be included in the editor after all the outputs are created/saved.
Ilaria Shireen Sestili
Ilaria Shireen Sestili 2020 年 7 月 22 日
thanks!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeDiscrete-Event Simulation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by