I have bmp images in the image folder on my computer. I called it from 1.bmpto 100.bmp.
1.bmp
100.bmp
And I want to read these images as follows:
for i=1:100 s='C:\images'+i+'.bmp'; A=imread(s); end
But Matlab made a mistake. How to implement this?
You can use the function sprintf
sprintf
s = sprintf('c:\images%d.bmp', i); A = imread(s);
You can read more about string handling in matlab here.
Create sas follows:
s
s = ['C:\images\' int2str(i) '.bmp'];
In addition, your loop will simply overwrite A, so you will have to make it a cell array in order to save all 100 images. Do this outside your loop:
A
A = cell(1,100);
:
A{i} = imread(s);
. C:\images1.bmp. , , , , ypnos.
C:\images1.bmp
imgfiles=dir('c:\images\*.*'); for k=1:length(imgfiles) ... end
matlab .
files=dir('*.bmp') for k=1:numel(files) I=imread(files(k).name); end
.
> for i=1:100 > s=strcat('C:\images',num2str(i),'.bmp'); > try > A=imread(s); > catch > end > end
num2str, , try aviod , , aviod .
Source: https://habr.com/ru/post/1713135/More articles:Are there any ALIPAY APIs for PHP integration? - phpFile does not start with "% PDF-" - internet-explorer-8At what level should I implement communication between nodes in a distributed system? - distributedIs there any cool course for FogBUGZ? - fogbugzGetting callback from OS X When does the Foucs application change? - javaReturn code in Capistrano .. for a PHP project - phpfreebsd: ΡΠ΅ΠΊΡΡΠΈΠΉ Π΄ΠΈΠ½Π°ΠΌΠΈΡΠ΅ΡΠΊΠΈΠΉ ΡΠΈΠΊΠ» ΠΏΡΠΎΡΠ΅ΡΡΠ° ΠΏΠΎ ΠΈΠ΄Π΅Π½ΡΠΈΡΠΈΠΊΠ°ΡΠΎΡΡ ΠΏΡΠΎΡΠ΅ΡΡΠ° - processManaging a user session on a web server for an iPhone application user - phpWhat is the "COM Context" mentioned in the MDS "ContextSwitchDeadlock" message? - clrSQL. Π§ΡΠΎΠ±Ρ Π½Π°ΠΉΡΠΈ ΡΠ°Π·Π½ΠΈΡΡ ΠΌΠ΅ΠΆΠ΄Ρ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΈΠΌΠΈ ΡΡΡΠΎΠΊΠ°ΠΌΠΈ - sqlAll Articles