好东西

源代码在线查看: convert.m

软件大小: 170 K
上传用户: omica
关键词:
下载地址: 免注册下载 普通下载 VIP

相关代码

				function out=convert(num,step,K)
				%num待转化的十进制数,step进制数,K转化后位数
				quotient=num;
				conv_num=zeros(1,K);
				flag=0;
				for k=1:K
				    if quotient>1
				        conv_num(k)=rem(quotient,step);
				        quotient=floor(quotient/step);
				    elseif quotient==1
				        conv_num(k)=1;
				        quotient=0;
				    else
				       conv_num(k)=0; 
				    end
				end
				out=fliplr(conv_num)';
				    
				    
				    
							

相关资源