Как уже отмечалось, в MATLAB все строки в массиве должны быть одинаковой длины. Чтобы иметь строки разной длины, используйте массив ячеек:
name = {};
for i = somearray
name = [name; {string}];
end
Функция add-to-list проверит автоматически перед добавлением
(setq a '(1 2 3))
(add-to-list 'a 4)
(add-to-list 'a 3)
приведет к a
, равному (4 1 2 3)
из Ch f add-to-list:
add-to-list is a compiled Lisp function in `subr.el'. (add-to-list list-var element &optional append compare-fn) Add element to the value of list-var if it isn't there yet. The test for presence of element is done with `equal', or with compare-fn if that's non-nil. If element is added, it is added at the beginning of the list, unless the optional argument append is non-nil, in which case element is added at the end. The return value is the new value of list-var. If you want to use `add-to-list' on a variable that is not defined until a certain package is loaded, you should put the call to `add-to-list' into a hook function that will be run only after loading the package. `eval-after-load' provides one way to do this. In some cases other hooks, such as major mode hooks, can do the job.