In the following matlab code,
random_numbers = randn(1,1000);
j=1;
for i=1:length(random_numbers)
if random_numbers(i) > 2.0
extracted(j) = random_numbers(i)开发者_JS百科;
j = j + 1;
end
end
save 'sample1' extracted
we get the following error:
??? error ==> save
Unable to write file sample1: permission denied.
error ==> test at 9
save 'sample1' extracted
Please advise.
A permission denied
error would suggest that you are trying to save to a directory to which you do not have write permission. Since you have specified just a base name for the filename, save
will try to save the MAT-file to the current working directory, which you can determine by running the command pwd
. You can also check the permissions of the current directory by running
[success, message] = fileattrib
and inspecting the UserWrite
field of the returned message
.
I have the same problem. This can be fixed by changing the current directory. Use pwd to check the current diretory
Try this instead:
save('sample1', 'extracted');
or:
save sample1 extracted
精彩评论