按块导入文本文件数据?

时间:2015-08-04 06:18:32

标签: matlab

我正在尝试导入以'//'开头的每一行,我尝试使用下面的脚本提取它。请问有人查看我的剧本吗?

enter image description here

formatSpec = '//NFE=%f //ElapsedTime=%f //SBX=%f //DE=%f //PCX=%f //SPX=%f //UNDX=%f //UM=%f //Improvements=%f //Restarts=%f //PopulationSize=%f //ArchiveSize=%f //MutationIndex=%f %*f';
N=1
k = 0;
while ~feof(fileID)
k = k+1;
C = textscan(fileID,formatSpec,N,'CommentStyle','#','Delimiter','\n');
end

1 个答案:

答案 0 :(得分:1)

我不清楚你想要输出的样子,但这里有一个可能性:

public class Main Frame extends J Frame {
private static final long serialVersionUID = 1L;
   public MainFrame(String title) {
    super(title);
    setLayout(new BorderLayout());
    JTextArea textArea = new JTextArea("test");
    textArea.setBounds(10, 10, 50, 20);
    JButton button = new JButton("Click me");
    button.setBounds(10, 20, 50, 20);
    Container c = getContentPane();
    c.add(textArea, BorderLayout.CENTER);
    c.add(button, BorderLayout.SOUTH);
}

public static void main(String args[]) {
    MainFrame frame = new MainFrame("Title");
    frame.setSize(500, 400);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}

结果包含两种类型,例如NFE或SBX,以及数字(尽管是字符格式)。

相关问题