在MATLAB中将字母映射为整数 [英] Mapping letters to integers in MATLAB

查看:127
本文介绍了在MATLAB中将字母映射为整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

函数 arithenco 要求输入消息为正整数序列.因此,我需要使用以下映射将消息转换为数字序列message_int.

The function arithenco needs the input message to be a sequence of positive integers. Hence, I need convert a message into a sequence of numbers message_int, by using the following mapping.

"A"→1,"C"→2,"G"→3,"T"→4.

‘A’→1, ‘C’→2, ‘G’→3, ‘T’→4.

推荐答案

据我了解,您所使用的字母仅包含四个值A,C,G,T(我想是DNA序列).

From what I understand, the alphabet you are using contains only four values A,C,G,T (DNA sequences I suppose).

简单的比较就足够了:

seq = 'TGGAGGCCCACAACCATTCCCTCAGCCCAATTGACCGAAAGGGCGCGA';
msg_int = zeros(size(seq));
msg_int(seq=='A') = 1;
msg_int(seq=='C') = 2;
msg_int(seq=='G') = 3;
msg_int(seq=='T') = 4;

这篇关于在MATLAB中将字母映射为整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆