matlab软件里数制相互转换10进制转换成11,12,13,14,15进制,不要其他编程语言,只要matlab里的程序

已知10进制数x,需要将其转换成y进制的数,输出为变量“s”(y=11,12,13,14,15)求编程代码,主要是不会用A表示10,B表示11……E表示14最好能给个de... 已知10进制数x,需要将其转换成y进制的数,输出为变量“s”(y=11,12,13,14,15)
求编程代码,主要是不会用A表示10,B表示11……E表示14
最好能给个dec2hex函数的实现过程代码
展开
 我来答
百川一归大海
2013-08-28 · TA获得超过1543个赞
知道小有建树答主
回答量:4318
采纳率:55%
帮助的人:969万
展开全部
function h = dec2hex(d,n)
%DEC2HEX Convert decimal integer to hexadecimal string.
%   DEC2HEX(D) returns a 2-D string array where each row is the
%   hexadecimal representation of each decimal integer in D.
%   D must contain non-negative integers smaller than 2^52.
%
%   DEC2HEX(D,N) produces a 2-D string array where each
%   row contains an N digit hexadecimal number.
%
%   Example
%       dec2hex(2748) returns 'ABC'.
%
%   See also HEX2DEC, HEX2NUM, DEC2BIN, DEC2BASE.

%   Copyright 1984-2006 The MathWorks, Inc.
%   $Revision: 5.15.4.8 $  $Date: 2008/08/26 18:22:07 $

bits32 = 4294967296;       % 2^32

if nargin<1
    error(nargchk(1,2,nargin,'struct'));
end

d = d(:); % Make sure d is a column vector.

if ~isreal(d) || any(d < 0) || any(d ~= fix(d))
    error('MATLAB:dec2hex:FirstArgIsInvalid','First argument must contain non-negative integers.')
end
if any(d > 1/eps)
    warning('MATLAB:dec2hex:TooLargeArg',...
        ['At least one of the input numbers is larger than the largest',...
        'FLINT (2^52).\n         Results may be unpredictable.']);
end

numD = numel(d);

if nargin==1,
    n = 1; % Need at least one digit even for 0.
end

[f,e] = log2(double(max(d)));%#ok
n = max(n,ceil(e/4));
n0 = n;

if numD>1
    n = n*ones(numD,1);
end

%For small enough numbers, we can do this the fast way.
if all(d<bits32),
    h = sprintf('%0*X',[n,d]');
else
    %Division acts differently for integers
    d = double(d);
    d1 = floor(d/bits32);
    d2 = rem(d,bits32);
    h = sprintf('%0*X%08X',[n-8,d1,d2]');
end

h = reshape(h,n0,numD)';

自己看看能不能改,不能再联系我

真greatdju
2013-08-28 · TA获得超过3852个赞
知道小有建树答主
回答量:1300
采纳率:91%
帮助的人:691万
展开全部

matlab自带的函数de2bi可以转换10进制到任意进制

clear;clc;


x=22
y=12

s='0123456789ABCDEFGIJKLMNOPQRSTUVWXYZ';%如果需要转换为更高进制,可以自定义对应的字母
s(1+de2bi(x,[],y,'left-msb'))
本回答被提问者和网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式