We have an exciting announcement about badges coming in May 2025. Until then, we will temporarily stop issuing new badges for course completions and certifications. However, all completions will be recorded and fulfilled after May 2025.
Photonics – Chinese

Photonics – Chinese

Topics related to Lumerical and more, in Chinese language.

Ansys Insight: 如何将结果数据如何保存成txt格式

    • Guilin Sun
      Ansys Employee
      一般建议直接保存为Lumerical文件格式: save - Script command 或者保存为Matlab格式:matlabsave - Script command 方法是
      matlabsave(“filename”, var1, …, varN);##Saves the specified workspace variables to the .mat file. 例如 x=1:10; y=x^2; matlabsave(“x_squared_data”, x, y); 使用Matlab读取后,可以直接用x, y作为变量使用。 它们均可以保存数据、变量和DATASET。   如果一定要用xtx格式,有几种方法输出数据:
      1:用脚本Write: write(my_string); ##Write my_string to the standard output (linux only).Linux使用 write(“testfile.txt”, my_string); ##Will write the contents of the string variable my_string to testfile.txt.将数据保存到testfile.txt 。内部实际些的是字符,因此数字需要转换,见下列脚本
      -------define the variables to export a=linspace(0,2*pi,9);
      b=sin(a); -----combine both vectors into a single 2D matrix to be output to file
      data_to_print= [a,b]; ----- write the data to the file
      write(“testfile.txt”,num2str(data_to_print)); 或者使用循环语句,一次给出一个a和b的数值,中间可按空格或者逗号隔开,参见
      --------- write the data to the file
      for (i=1:length(a) ) { str= num2str(a(i))+", "+num2str(b(i)); write(“testfile.txt”,str); }
       
      2:在Visualizer里直接输出 在Script Workspace选一个变量,点左键显示Visualizer,或者通过监视器的Visualizier,将结果画出来,然后点Export to,选text:
Viewing 0 reply threads
  • The topic ‘Ansys Insight: 如何将结果数据如何保存成txt格式’ is closed to new replies.