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

YS
YS 2023년 12월 26일
Hi, i met the same error. Could you please tell me how to address this error? Thank you very much!
Walter Roberson
Walter Roberson 2023년 12월 26일
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}
YS
YS 2023년 12월 26일
thank you! it works!

댓글을 달려면 로그인하십시오.

 채택된 답변

dpb
dpb 2013년 10월 2일

1 개 추천

??? 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