why file did not appear

1 次查看(过去 30 天)
farina
farina 2024-5-24
评论: DGM 2024-5-24

回答(2 个)

DGM
DGM 2024-5-24
Maybe it has something to do with that big red error because you created an invalid file name.
  2 个评论
Steven Lord
Steven Lord 2024-5-24
That was the first thing I noticed too. MATLAB program files cannot have spaces in their names. Rename it to something like image1.m or image_1.m and try running it again.
Looking at the Files list, the next problem you're likely to encounter is that there's probably no "image 1.jpg" file in a location accessible to MATLAB. Find it and put it in your MATLAB Drive files or in a directory on the MATLAB Search Path (like the directory whose name is returned by the userpath function.)
DGM
DGM 2024-5-24
Strangely enough, I went ahead and tried this and it seems that a person could get blindsided or confused by this sort of thing depending on how they use the editor.
I always use ctrl-enter to run scripts in cell mode. In that manner, no error is produced.
If you use F5 run or the ribbon, you will get an error. In R2024a in MATLAB online, I get an error about the filename being invalid. In R2019b, I get the following error:
Error using image
Color data must be numeric or logical values.
... which happens because of the split filename now being interpreted as an existing function. You're just two characters away from a different type of naming problem.

请先登录,再进行评论。


Pratyush Swain
Pratyush Swain 2024-5-24
Hi farina,
As your image file is not visible in the "Files" Directory, I would first suggest to make sure your image file - 'image 1.jpg' is uploaded to this directory in MATLAB Drive. To access your MATLAB Drive, you can visit https://drive.mathworks.com/ or access it from the matrix menu at https://matlab.mathworks.com/.
You can also follow the workarounds mentioned in this MATLAB Answers thread as follows: https://www.mathworks.com/matlabcentral/answers/409750-imshow-not-working
Hope this helps.

类别

Help CenterFile Exchange 中查找有关 Search Path 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by