Convert individual values in a matrix to letters and keep remaining as numbers
Show older comments
Hi,
I'm trying to fill in characters corresponding to elements in the array airline_names into the array Usage using the below code:
Usage = num2cell(CounterUsage);
airline_names = cellstr(['AC_ '; 'FI_ '; 'QR_ '; 'SK_C'; 'SQ_ '; 'STB '; 'STE '; 'TG_ ']);
for i=1:33
for j=1:288
if isequal(Usage(i,j),0) ;
else
Usage(i,j)=num2cell(double('AB'));
%else
%Usage(i,j) = num2str(airline_names(CounterUsage(i,j)));
end
end
end
Usage is a matrix of values from 0 to 8 where I want all non zero elements to be replaced by the corresponding element in airline_names, e.g. Usage(i,j) = 1 then 1 should be replaced by airline_names(1) = 'AC_ '
However, the above code doesn't work due to what I think might be some type/format errors..
Please help!:D
Best Regards Maria and Christian
Accepted Answer
More Answers (0)
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!