What changes are needed in the code?
1 view (last 30 days)
i want to swaps characters of s as specified by the indices present in the pairs variable. pairs is a 2-column matrix, where on each row, i have given the positions of the two characters that need to swap. eg s = orange & pairs = [1 2]. out expected is roange. what changes you recommend in this code.
function [arr] = shuffletext ( pairs, s)
a = 0;
b = 0;
for i = 1:numel(s)
for j = pairs
s(i) = a;
a = b;
b = s(i);
arr = b;
Still its not showing any output just a blank if i call the function
using: disp( shuffletext( [1 2], 'orange') )
>> disp( shuffletext( [1 2], 'orange') )