Hi @Paul
I tested this with both PLECS Standalone and PLECS Blockset.
For a MAT file, the string should be stored as a character array, for example:
config = 'MMCA1';
save('test.mat', 'config');
The file can then be loaded during initialization with:
load('test.mat');
This works with both PLECS Standalone and PLECS Blockset.
The reason is that in MATLAB
config = 'MMCA1';
creates a character array, while
config = "MMCA1";
creates a MATLAB string object. These are different data types. PLECS can read character arrays from MAT files, but MATLAB string objects are not supported by the PLECS MAT-file interface. Therefore, if the MAT file is intended to be loaded by PLECS, the value should be converted to a character array before saving, for example:
config = char(config);
save('test.mat', 'config');
An alternative is to put the initialization into an M-file and execute it with:
run('test.m');
For example:
config = 'MMCA1';
Using single quotes is also the portable choice here.
There is a small difference between Standalone and Blockset that can otherwise be confusing. PLECS Standalone evaluates the M-file using its Octave-compatible scripting environment, where double-quoted text can be handled as a character string. PLECS Blockset executes the M-file in MATLAB, where "MMCA1" creates the MATLAB-specific string type.
Therefore, if the same initialization file should work with both PLECS Standalone and PLECS Blockset, I recommend using:
config = 'MMCA1';
load_string_R2020b.slx (21.0 KB)
load_string.plecs (8.3 KB)
test.m (73 Bytes)