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.

조회 수: 10(최근 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
Stephen23
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
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
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개)

Community Treasure Hunt

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

Start Hunting!

Translated by