Saving a 1x2 structure with 5 fields
    조회 수: 5 (최근 30일)
  
       이전 댓글 표시
    
I am trying to save my structure that I've called "mymat" in the workplace area as a file. When I try to save it like:
>> save ('mysummat.mat', '-struct', 'mymat');
I get the error message:
Error using save
The argument to -STRUCT must be the name of a scalar structure variable.
When I try to save it like:
>> save ('mysummat.mat', 'mymat')
I get the error message:
Error using save
Unable to write file mysummat.mat: No such file or directory.
I just want to be able to save this structure array specifically.
댓글 수: 1
  Stephen23
      
      
 2016년 7월 14일
				
      편집: Stephen23
      
      
 2016년 7월 14일
  
			Never use the name of an inbuilt function to name your own function or variable
This means you should never use sum, length, mean, size, i, j, etc, etc.
This will only cause untold heartache and hard to diagnose problems. Use which to check names before you use them.
답변 (1개)
  Azzi Abdelmalek
      
      
 2016년 7월 14일
        First, avoid using sum as a variable because it's a built-in Matlab function
som.a=4
som.b=5
save ('mysum.mat', '-struct', 'som')
댓글 수: 5
참고 항목
카테고리
				Help Center 및 File Exchange에서 Scope Variables and Generate Names에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


