printf - Matlab: fprintf error -


i need save data in .txt file, works great except 1 line.

%writing rest of data file fprintf(fid, '%u',speednum); fprintf(fid, ' '); fprintf(fid,speedunit); %that line 

in speedunit different values (none work) 1 of is: 'frames per min '

the error is:

error using fprintf invalid format.

error in rackwriter>tag_onoff_callback (line 414) fprintf(fid,speedunit);

error in gui_mainfcn (line 95) feval(varargin{:});

error in rackwriter (line 42) gui_mainfcn(gui_state, varargin{:});

error in @(hobject,eventdata)rackwriter('tag_onoff_callback',hobject,eventdata,guidata(hobject))

error while evaluating uicontrol callback

can me??? thank in advance

fprintf(fid, ' '); fprintf(fid,speedunit); 

are both function calls 2 input arguments. in documentation of fprintf you'll find this:

fprintf(formatspec, a1) formats data , displays results on screen.

so in function calls fprintf tries use fid format specification. not possible, therefore error.

fprintf(fid, '%s', ' '); fprintf(fid, '%s', speedunit); 

should fix problem.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -