Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++
for i=1:5
    for j=1:5
        fnsil=fprintf('sad%d%d.wav'i,j);
        fid=fopen(fnsil,'r');
        fr=fscanf(fid,'%f',1);
        fclose(fid)
        for a=1;fr
            kk=fscanf(fid,'%f',1);
            ex(i)=kk
        end;
    end;
end
Posted
Updated 3-Oct-15 21:09pm
v2
Comments
Member 12030492 3-Oct-15 13:58pm    
i have error in this code
Richard MacCutchan 4-Oct-15 3:08am    
What error, where does it occur, what is the code supposed to do?
[no name] 3-Oct-15 14:39pm    
Do you mean copy or what?

1 solution

I don't know Matlab but I'm quite sure that reading from a closed file descriptor will fail there too. There are also some missing semicolons and one loop range contains a colon rather a semicolon. So you may try this:
C
for i=1:5
    for j=1:5
        fnsil=fprintf('sad%d%d.wav'i,j);
        fid=fopen(fnsil,'r');
        fr=fscanf(fid,'%f',1);
        for a=1:fr % Replaced ; by :
            kk=fscanf(fid,'%f',1);
            ex(i)=kk; % Added missing semicolon here
        end % Removed unnecessary semicolon
        fclose(fid); % Moved to here and added missing semicolon
    end % Removed unnecessary semicolon
end
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900