How to write each iteration (data) in for loop to excel and how to read multiple excel files together?
36 views (last 30 days)
I have 20 excel files (subjects) and I want my code to read each excel file in one matlab code and perform the following operations for each excel file. In the below code, my code performs calculations for only one subject (excel file).
Each subject has 15 stages for the two variables and I want to write the value in each stage for the two variables (c and n) to the excel. However my code only writes the last value since it overwrites it. The aim of the code is to find raw values and finding the corresponding raw values of the two variables (c and n) for each 15 stage. And write them to the excel in this format (above are the names and below are their values):
c-1st stage c-2nd stage......c-15th stage n-1st stage n-2nd stage......n-15th stage
5 3 3 2 3 ..... 5
Could you please help me to solve these problems? I have tried some of the explanations in the forum but it did not work. Thank you so much.
raw(m)=find((count ==j) & (resp1 ==1) ;
Abderrahim. B on 7 Aug 2022
With the below command you are overwriting output1.xlsx file, hence you are only getting the last written file.
Try something like this:
filename = "output" + num2str(m) + ".xlsx" ;
Hope this helps