I found this bellow code in internet. While I run the code I noticed following errors.
4 views (last 30 days)
Show older comments
clc
clear all;
close all;
filename = 'Registration_Details.xls';
[num,txt] = xlsread(filename);
len=length(txt);
blankimage = imread('certificate_Blank.tiff');
for i=1:len
for j= 2:2
text_names(i,j)=txt(i,j);
end
end
% Obtain names from the txt variable which are in 2nd column
for i=1:len
for j= 3:3
text_topic(i,j)=txt(i,j);
end
end
for i=2:len
text_all=[text_names(i,2) text_topic(i,3)];
position = [100 258;120 416];
RGB = insertText(blankimage,position,text_all,'FontSize',22,'BoxOpacity',0);
figure
imshow(RGB)
y=i-1;
filename=['Certificate_Topic_' num2str(y)];
lastf=[filename '.png'];
saveas(gcf,lastf)
end
Errors:
Error using matlab.graphics.internal.name (line 101)
Cannot create output file '.\Certificate_Topic_1.png'.
Error in print (line 71)
pj = matlab.graphics.internal.name( pj );
Error in saveas (line 181)
print( h, name, ['-d' dev{i}] )
Error in MainCode (line 36)
saveas(gcf,lastf)
0 Comments
Answers (1)
Jan
on 21 Nov 2019
This is a strange and inefficient code. Replace e.g.
for i=1:len
for j= 2:2
text_names(i,j)=txt(i,j);
end
end
to
text_names(:, 2) = txt(:, 2);
The actual error message can be caused by a write-protected folder. The solution is to write the output to a folder, in which you have write-permissions.
0 Comments
See Also
Categories
Find more on Scope Variables and Generate Names in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!