Hi. I want to automate a process which consists of 3 steps. 1. Read the data from excel file and extract the necessary data alone. 2. Run the data and output plots. 3. Store the results (workspace) in a specified folder in my computer.
2 次查看(过去 30 天)
显示 更早的评论
1. Read the data from excel file and extract the necessary data alone.
2. Run the data and output plots.
3. Store the results (workspace) in a specified folder in my computer.
Also, I want to do a batch simulation. That is run a code to read and perform the above three steps for multiple excel files at a time (or one after another automatically).
Please help
2 个评论
Raj
2019-12-10
编辑:Raj
2019-12-10
"extract the necessary data alone" - What is necessary data?
"Run the data" - What 'run' do you want to do?
"output plots" - What type of plot?
"perform the above three steps for multiple excel files at a time " - You will have to mention the file names and it should be a pattern that can be put in a loop.
Your question is way too vague. Atlease share a sample file and clearly specify what you want to do with it.
Stephen23
2019-12-10
Gokul Prassad's "Answer" moved here:
Hi Raj,
Thank you for your response.
I am doing analysis of various vehicle data like mass, accelertation, speed, torque,...
Consider I have 10 sets of data (10 vehicles) in 10 sheets of a single MS Excel file.
I want to plot Time vs Speed, Time vs Torque..... plots for each vehicle.
I want to call the master excel file into matlab, read/run the data in each sheet and save the workspace of each sheet in a specific folder.
At the end of the simulation, I want 10 result folders containing the workspace of 10 vehicles.
Hope I am clear.
Looking forward to your response.
采纳的回答
Raj
2019-12-10
编辑:Raj
2019-12-10
"I want to call the master excel file into matlab, read/run the data in each sheet and save the workspace of each sheet in a specific folder"
sheets = sheetnames('C:\Users\User\Data.xlsx') % Put your file path here
for ii = 1:length(sheets)
data{1} = xlsread('C:\Users\User\Data.xlsx',['Sheet'num2str(ii)]) % Read data from one sheet at a time
save data % Save workspace
mkdir(['Vehicle' num2str(ii)]) % Create new folder with vehicle number as folder name
movefile('data',['Vehicle'num2str(ii)]); % Move data to newly created folder
clear data % clear data from workspace and repeat for all the sheets.
end
It is not clear how you want the plot part. Do you want to save the plots, create new plots for each vehicle , overwrite or hold on? Whatever be the case, now that you have the data in workspace, extract the relevant data and plot according to your requirement.
2 个评论
Stephen23
2019-12-10
Gokul Prassad's "Answer" moved here:
Hi Raj,
Thanks a lot for that express response.
I will try this one out.
Stephen23
2019-12-10
Gokul Prassad's "Answer" moved here:
Hi Raj,
I am getting the following error.
Error: File: batch_sim.m Line: 3 Column: 105
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other
syntax error. To construct matrices, use brackets instead of parentheses.
num2Str is shown as invalid expression ! in line 3 and 6.
I replaced the parentheses with brackets and still get the same error
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!