why do i get this error "Undefined function or variable 'vect2mat'."?

as we know that vect2mat is in built function. I'm confused and worried about this error. Please help me with this!!
function [c]=enc(m,n,mpk)
m1=double(m);
size=numel(m1);
c1=m1;
for i=1:size
m2=m1(i)^mpk;
c1(i)=mod(m2,n);
end
count=6-rem(size,6);
if rem(size,6)==0
c2=vect2mat(c1,6);
else
count1=zeros(1,count);
c11=[c1,count1];
c2=vect2mat(c11,6);
end
n1=[mpk,n,0,0,0,0];
c=[n1;c2];

 채택된 답변

KL
KL 2017년 10월 20일
편집: KL 2017년 10월 20일

0 개 추천

you mean vec2mat?
Note that you'd need communication systems toolbox for that.
But otherwise you could use reshape!
Another thing, do not override the inbuilt functions! in your code, you're creating a variable called size, I'd suggest you to rename it.

댓글 수: 4

thank you so much for your immediate reply and i will follow your suggestion. But the reshape function aligns the vector elements in a column .I need function to align elements in row wise and go for another row. Is there any other way other than 'vect2mat'? I am new to MATLAB please help me. thank you.
You just need to transpose the output of reshape!
>> a = [1 2 3 4 5 6];
>> b = reshape(a,3,2)
b =
1 4
2 5
3 6
Now, let's try to transpose,
>> c = reshape(a,3,2).'
c =
1 2 3
4 5 6
thank you so much KL
You're welcome, accepting the answer would be a way to thank though!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2017년 10월 20일

댓글:

KL
2017년 10월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by