📄 pic.m
字号:
%function pic()
clear
%clc
s=input(['Input the file''s name(The name must be English!): '],'s');
M=fopen([s,'.txt'],'rt');
if M>0
disp('Open file successfuly!');
[f,count]=fscanf(M,'%c');
disp(['There are ',num2str(count),' Bytes.']);
while(1)
n=input('Input the size you want to pice:');
if n>=count||n<=0
disp(['The size is error! The size must be less than ',num2str(count),'!']);
else
break
end
end
sz=count/n;
if max(1:sz)==sz
page_num=sz;
else
page_num=max(1:sz)+1;
end
disp(['The file will be piced to ',num2str(page_num),' pices.']);
i=1;
while(i<=page_num)
file_name=[s,'_',num2str(i),'.txt'];
file_num=fopen(file_name,'wb');
if i<=page_num-1
byt_num=((i-1)*n+1):(i*n);
fwrite(file_num,f(byt_num),'char');
else
byt_num=((i-1)*n+1):count;
fwrite(file_num,f(byt_num),'char');
end
fclose(file_num);
i=i+1;
end
c=fclose(M);
if (c==0)
disp('Closed successfuly!')
else
error('Closed failed!!')
end
else
error('Open failed!!');
end
clear
%[M] = fopen('jd.txt','rt');
%[f,count]=fscanf(M,'%c')
%m2=fopen('jd2.txt','wb')
%m3=fopen('jd3.txt','wb')
%fwrite(m2,f(1:200),'uchar')
%fwrite(m3,f(201:600),'uchar')
%fclose(m2)
%fclose(m3)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -