Function is not defined for 'cell' inputs
120 views (last 30 days)
Show older comments
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 Comments
Walter Roberson
on 26 Dec 2023
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}
Accepted Answer
dpb
on 2 Oct 2013
??? 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})
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!