Function is not defined for 'cell' inputs

Please help me. This is my code but i have a problem
??? Error using ==> sprintf Function is not defined for 'cell' inputs.
clear; close all; clc;
DirName='C:\Matlab';
Organ={'Colon'}; Mag={'10x'}; TimePt={'3hr'}; MouseNum=[1]; SampleNum=[1];
%fid=fopen('results.csv','w'); %fprintf(fid,'Organ;Time Point;Mouse Number;Site;GFP_Total_G;GFP_Total_R;Cy3_Total;Tissue_Pixels\r');
load corectimage;
% Create filename and open the images if strcmp(Organ,'Colon') FileNameG=sprintf('%s\\%s\\%s\\%s\\M%d-E1-I800-G-%d.tif',DirName,Organ,TimePt, Mag, MouseNum, SampleNum); imG=imread(FileNameG,'TIFF'); FileNameC=sprintf('%s\\%s\\%s\\%s\\M%d-E1-I800-C-%d.tif',DirName,Organ,TimePt, Mag, MouseNum, SampleNum); imC=imread(FileNameC,'TIFF'); else FileNameG=sprintf('%s\\%s\\%s\\M%d-E1-I800-G-%d.tif',DirName,Organ,TimePt, MouseNum, SampleNum); imG=imread(FileNameG,'TIFF'); FileNameC=sprintf('%s\\%s\\%s\\M%d-E1-I800-C-%d.tif',DirName,Organ,TimePt, MouseNum, SampleNum); imC=imread(FileNameC,'TIFF'); end;
% Correct the image intensity (only for Mag=4x) if strcmp(Mag,'4x') imG=double(imG); imC=double(imC); load(sprintf('%s\\corectimage.mat',DirName)); imG(:,:,1)=imG(:,:,1).*imXG; imG(:,:,2)=imG(:,:,2).*imXG; imG(:,:,3)=imG(:,:,3).*imXG; imC(:,:,1)=imC(:,:,1).*imXC; imC(:,:,2)=imC(:,:,2).*imXC; imC(:,:,3)=imC(:,:,3).*imXC; imG=uint8(imG); imC=uint8(imC); end;
imshow(imG);
%fclose(fid);

3 个评论

Hi, i met the same error. Could you please tell me how to address this error? Thank you very much!
At some point in your code, you have an sprintf() that attempts to format a cell array. You need to change that so that it attempts to format the content of the cell array.
For example, instead of attempting to format cell_Var(i) instead format cell_Var{i}
thank you! it works!

请先登录,再进行评论。

 采纳的回答

??? Error using ==> sprintf Function is not defined for 'cell' inputs.
That's correct; either use
sprintf(fmtstring,char(cellVar(i)))
or be sure to dereference the cell by using the curly braces --
sprintf(fmtstring, cell_Var{i})

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Images 的更多信息

标签

提问:

2013-10-2

评论:

YS
2023-12-26

Community Treasure Hunt

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

Start Hunting!

Translated by