How to write the multiple txt file from multiple simulation results

#1

Hi

I created a script that reads multiple simulation (Transmission versus wavelength spectrum) from the monitor in each simulation and write the txt file in each time, which can be read from Matlab.

When I run the script, it shows the following errors.

Can you take a look at my script?

#2

Hello,

I think you may have forgotten to include the error message.
Anyway, a few things that I can see.

Firstly, line 28 probably has a spelling mistake in the first term as I guess you meant
FinalMatrix=[FinalMatrix,T.T];

Secondly, is there any particular reason why you only read the wavelength for the first file? I understand that it’s the same for all files, but it simplifies the code if you just get it to read the wavelength each time. Then there’s no need for the if and else commands.

Lastly, if you only want to read the wavelength once, I think there’s something wrong in your logic. Without seeing your file I am not sure, but I think that line 23 is meant to get the wavelength. Then line 24 combines this wavelength with the transmission data and then overwrites the original wavelength information with this new 2D array. The trouble is that this means that line 28 is then trying to combine this 2D array with the new transmission instead of just the wavelength and the new transmission.
As a guess I would replace line 23 with
lambda = T.lambda;
and then replace both line 24 and line 28 with
FinalMatrix=[lambda, T.T];
Hopefully that works, but I would still just get read of the if and else to keep things simple.

#3

Hi,

Thank you so much, it is solved easily.