a1 = [0 32]; c1 = ([31 63]);d1 = unique([a1 c1]);first = ['[' num2str(d1(1)) ':' num2str(d1(2)) ']'];second =['[' num2str(d1(3)) ':' num2str(d1(4)) ']'];preresult= [ first second];result = ['{' preresult '}'];%result = {[0:31][32:63]}
How can I make this code worked more generally, for any values of a1 and c1? I've tried with this :
newArray =[]; for i=1:length(a1) newArray(length(newArray)+1)= [ '[' num2str(a1(i)) ':' num2str(c1(i)) ']' ] end But it said Subscripted assignment dimension mismatch. Can someone help me maybe? :(
Best Answer