[20220420] [Matlab] wrong use of save, must be a string scalar or string solution ~

1. Error message

        Error using save must be a string scalar or character vector.

clear; clc;

a = 10;
path = 'D:\';
name = 'matData';
path_name = fullfile(path, name);
save(path_name, a);

2. The reason for the error

        Matlab's save function uses strings to find variables in the workspace. So add single quotes to a~

        (Reference: Matlab cyclically stores variables as .mat and the save function reports an error: Error using the save parameter must contain a string (Argument must contain a string.) processing method

Guess you like

Origin blog.csdn.net/weixin_40583722/article/details/124298577