how to write values to excel sheet

3 ビュー (過去 30 日間)
nkumar
nkumar 2015 年 6 月 28 日
コメント済み: Image Analyst 2015 年 8 月 3 日
I have 100 variables as output say for example res1 ,res2, val1,val6 in command window.Now I want to write all these into excel sheet.In xlswrite command I am able to write as one variable xlswrite('filename.xls',res1),it takes time for writing all 100 variables,is there any easy method to do this.Another method I tried out=[res1;res2;val1;val6] and use xlswrite,for fewer variables we can cancatanate,but for 100 variables is there any easy method to do this.

回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 6 月 28 日
Can you give more details about your arrays, are they same size? What about the names? maybe you should save all your result in one variable
  6 件のコメント
nkumar
nkumar 2015 年 6 月 28 日
I tried it,my Simulink model consists of 'from workspace block' and other variales and values,i get error .coz of different dimensions.that the reason for posting above question,is it possible to obtain results from Simulink model using To workspace blocks
Azzi Abdelmalek
Azzi Abdelmalek 2015 年 6 月 28 日
Check the sizes of your data

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


Image Analyst
Image Analyst 2015 年 6 月 28 日
You can save all your variable to one numerical array or one cell array. Then call xlswrite(). You're not calling xlswrite 100 times are you? Because that WILL take an enormous amount of time. If you're unable to collect all your variables into one array at one time, then let me know why, and I can help you figure out how to do it. Otherwise you can use ActiveX which will be very fast even with 100 different pokes. I attach a demo for you.
  8 件のコメント
nkumar
nkumar 2015 年 8 月 3 日
I have done like this before but it is manual process Saving every variable in cell array. I like to know is any for loop will be used such tat the task become easier. Because my variable may vary Now I have A1,A2 etc.other time it may differ
Image Analyst
Image Analyst 2015 年 8 月 3 日
No it doesn't really get easier. That's what you get for unwisely deciding to have 100 variables with different names. Not only different but with different names on each run. What a disaster. Please read the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F
You dug your own grave but it's not too late to get out. Just use regular programming methods like most people would.

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

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by