Search code examples
matlabloggingtextoutputnon-printing-characters

Textual output appears wrong and contains inexplicable symbols


When I run my code the output appears like an error. What can be done about this?

Here's the part of my code that does the printing:

if (dtw(Bs(:,4),AY) > 40) && (dtw(Bs(:,4),AY)< 68) 
    SOEvent=1;
    X=['event is', SOEvent,'in duration',(i:i+200)];
    disp(X);
elseif (dtw(As(:,4),AY) > 60 ) && (dtw(Bs(:,4),AY)< 130) 
     SOEvent=2;   
      X=['event is', SOEvent,'in duration',(i:i+200)];
    disp(X);

elseif (dtw(LLchs(:,4),AX) > 105) && (dtw(LLchs(:,4),AX)< 190)
        SOEvent=3;
         X=['event is', SOEvent,'in duration',(i:i+200)];
    disp(X);
elseif (dtw(Rlchs(:,4),AX) > 55) && (dtw(Rlchs(:,4),AX)< 100) 
    SOEvent=4;
     X=['event is', SOEvent,'in duration',(i:i+200)];
    disp(X);

 else 
     disp('no event')

end

The output of the code is:

event isin durationÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑ
no event
no event
event isin

Solution

  • Use num2str to convert numbers to strings (or character arrays) so that they can be concatenated and printed using disp.

    Please make sure you format your code properly when you ask questions, because the cause of the problem (placeholder characters) is only visible when looking at your raw post (i.e. editing).