MATLAB Code not working. Trying to store input into an array -
i wrote 2 functions, first 1 encrypt
prompt = 'enter sentence encrypt'; dlg_title = 'input'; num_lines = 5; defaultans = {'hello'}; answer = inputdlg(prompt,dlg_title,num_lines,defaultans); answer = answer{1}; % find out how big square matrix data should = 1:length(answer) % should never run far anyway if (i^2) > length(answer) break; end end mat_len = i; % predefine square matrix of numbers forcing matrixa number type matrixa = zeros(mat_len,mat_len); % iterate through square matrix assigning answer values positions = 1:mat_len j = 1:mat_len if (((i-1)*mat_len)+j) <= length(answer) matrixa(i,j) = answer(((i-1)*mat_len)+j); else break; end end end matrixa(1)=matrixa(1)*10 matrixa'
this stores ascii code array matrixa , simple matrix operations hide message. instance hello be
720 108 0 101 111 0 108 0 0
the second function problem is, spossed take input of matrix , convert message. 720 turns 72 h. function instead reads matrixa stored.
prompt = 'enter code decrypt'; dlg_title = 'input'; num_lines = 5; defaultans = {''}; answer = inputdlg(prompt,dlg_title,num_lines,defaultans); answer = answer{1}; = 1:length(answer) % should never run far anyway if (i^2) > length(answer) break; end end mat_len = i; % predefine square matrix of numbers forcing matrixa number type matrixa = zeros(mat_len,mat_len); % iterate through square matrix assigning answer values positions = 1:mat_len j = 1:mat_len if (((i-1)*mat_len)+j) <= length(answer) matrixa(i,j) = answer(((i-1)*mat_len)+j); else break; end end end matrixa'' matrixa(1)=matrixa(1)/10 m2=matrixa.'; result=char(m2(:)).'; result
this code not work. how can read matrix of numbers , convert them characters.
Comments
Post a Comment