2013-06-27 9 views
2

다음 코드를 작성하여 '데이터 파일'에있는 데이터로 그래프를 그렸습니다. 그래프가 그려지면 파일을 지우고 싶습니다. // %가 ________ % 나Scilab의 함수를 통해 파일을 삭제할 수 없습니다.

deletefile(datafile); 

그 중

mdelete(datafile); 

없음을 일하지 않은

을 시도로서 내가 표시 한 장소에서
function plot_torque(datafile) 
    //This will call a datafile and plot the graph of net_torque vs. time 
    verbose = 1; 
    // Columns to plot 
    x_col = 1; 
    y_col = 2; 
    // open the datafile 
    file1 = file('open', datafile,'old'); 
    data1 = read(file1, -1, 4); 
    time = data1(:,x_col); 
    torque = data1(:,y_col); 
    plot(time, torque, '.-b'); 
    xtitle("Torque Generated vs. Time" ,"Time(s)" , "Torque Generated(Nm/m)"); 
    file('close',file()); 
    //%________________% 
endfunction 

. 그리고 위의 '.sci'파일이 있고 'datafile'이있는 작업 디렉토리를 설정했습니다. 나는 scilab-5.4.1을 사용하고 있습니다.

+0

제거하려고 할 때 어떤 기능을 반환합니까? 절대 파일 경로를 지정하십시오. –

답변

0

파일을 열어두면됩니다. 이것을 시도하십시오 :

fil="d:\Attila\PROJECTS\Scilab\Stackoverflow\file_to_delete.txt"; //change it! 
fprintfMat(fil,rand(3,3),"%.2g"); //fill with some data 

fd=mopen(fil,"r"); //open 
//do something with the file 

mclose(fd); //close 
//if you neglect (comment out) this previous line, the file remains open, 
//and scilab can not delete it! 
//If you made this "mistake", first you should close it by executing: 
// mclose("all"); 
//otherwise the file remains open until you close (and restart) Scilab! 

mdelete(fil); //this works for me 
관련 문제