Weird reading data: seed
조회 수: 1 (최근 30일)
이전 댓글 표시
I have data point (attached) and when I call it in command window: data.seed I get the right answer but when I use it in the script to as file .mat name saved, I get error and I see matlab reads it as seed. Any idea why?
The command I use:
name = strcat(struct(jjj).name,'_','seed',data.seed,'.mat');
The error I receive:
Unable to write file C:\Users\Zeynab\Desktop\jsonmatlab\Result\Local\K1_0.0\K1_0.0_seed.mat: Invalid argument.
Using another name rather than data.seed would work so I assume the problem is within data.seed
![1.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/242132/1.jpeg)
![2.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/242133/2.jpeg)
댓글 수: 0
답변 (1개)
Stephen23
2019년 10월 11일
편집: Stephen23
2019년 10월 11일
The problem is data.seed.
When you concatenate that numeric value onto character vectors MATLAB does not implcitly convert the numeric value to a character representation of that value, it actually converts it to the character whose character code is equal to that value. This is simple to demonstrate and resolve, see:
E.g. rather than awkward strcat yoiu could use neat and efficient sprintf:
name = sprintf('%s_seed%d.mat',struct(jjj).name,data.seed);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Guidance, Navigation, and Control (GNC)에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!