Matlab Doesn't Recognize Fits Files (evalin, sprintf)?
Show older comments
I need my script to read in five images (capture_667.fit... capture_671.fit), and name them image667... image 671. I have the following code:
for j = 667:671
evalin('base', sprintf('[ image%03d ] = fitsread(capture_%03d.fit);', j, j));
end
However, I get this error message:
.
'Undefined variable "capture_667" or class "capture_667.fit".
Error in Try_Sprintf_Evalin_New (line 5) evalin('base', sprintf('image%03d = fitsread(capture_%03d.fit);', j, j));'
.
All of the files I'm trying to read in are in the right folder. Furthermore, if I try to open these files manually, I get this message:
.
'Error using open (line 162) CFITSIO library error (412); datatype conversion overflow'
.
What's stopping my code from working? And what is a datatype overflow? I've looked online for a definition but with no luck.
NB: This task was set by demonstrators at university. I HAVE to complete it using sprintf, evalin, and fitsread.
Accepted Answer
More Answers (2)
Walter Roberson
on 16 Nov 2015
0 votes
If you need your code to do that, then it is time to renegotiate the requirements with who-ever imposed that constraint. Creating variables on the fly is not recommended at all.
3 Comments
MC
on 16 Nov 2015
Walter Roberson
on 16 Nov 2015
Well now you begin to see why we do not recommend using eval() or evalin() .
Is the requirement definitely for evalin()? You cannot use assignin() instead?
MC
on 16 Nov 2015
Categories
Find more on Image Category Classification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!