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~