parse.m

来自「实数编码的遗传算法」· M 代码 · 共 32 行

M
32
字号
function [x] = parse(inStr)% parse is a function which takes in a string vector of blank separated text% and parses out the individual string items into a n item matrix, one row% for each string.%% function [x] = parse(inStr)% x     - the return matrix of strings% inStr - the blank separated string vectorsz=size(inStr);strLen=sz(2);x=blanks(strLen);szstrLenxpausewordCount=1;last=0;for i=1:strLen,  if inStr(i) == ' '    wordCount = wordCount + 1;    x(wordCount,:)=blanks(strLen);    last=i;  else    x(wordCount,i-last)=inStr(i);    x    pause endend

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?