dlmread is not for reading text files.The easiest way to import a text file is with fileread.
Similarly, dlmwrite is not for writing text files. There's no one-line equivalent to fileread unfortunately:
filename = input('name of file to write', 's');
fid = fopen(filename, 'wt');
fprintf(fid, 'Cezar: %s\n', Szyfr);
fprintf(fid, 'Skok %s\n', key);
fclose(fid);
WIth regards to your code:
while key > 26
key = mod(key,26);
end
is a pointless loop. If key is greater than 26, the mod guarantees that it will be less than 26 after that regardless of how big it is. If it is less than 26, then the mod wouldn't change it, so the whole lot is simply:
I note that later on in your code, you seem to have forgotten about mod.
Finally, I'll leave you with this code:
plain = 'the quick brown fox jumps over the lazy fox!'
key = mod(input('Podaj skok:'), 26);
cypher('a':'z') = circshift('a':'z', -key);
encoded = plain;
encoded(isletter(plain)) = cypher(plain(isletter(plain)))
Best Answer