PDA

View Full Version : (matlab) GUI


vpervendetta
18-01-2013, 14:35
Ho un problema con l'implementazione di una GUI in matlab, io dovrei caricare alcuni dati tramite un pushbutton.
Cioe inserendo un codice nella command window questo funziona correttamente, inserendolo nel pushbutton non funziona, mi fa selezionare un file da caricare ma non mi carica nulla. Il codice in questione è:

Quello che metto nella command:
[nomefile1] = uigetfile('*.txt','Selezionare file txt...');
nomefile=nomefile1(1:end-4);
fid = fopen(nomefile1);

fidw=fopen(strcat(nomefile,'_v2.txt'),'w');

for i_=1:9
line=fgets(fid);
fprintf(fidw,line);
end

fs=prendi_fs(nomefile1);

while ~feof(fid)
line=fgets(fid);
line(1:15)=[' '];
i_=i_+1;
fprintf(fidw,'%s',line);
end

fprintf('Creato nuovo file: %s \r',strcat(nomefile,'_v2.txt'));

fclose(fid);fclose(fidw);
nomefile2=strcat(nomefile,'_v2.txt');

[data, no_el] = importdata_FLF(fs, nomefile2);


Quello del bottone:

% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
[nomefile1] = uigetfile('*.txt','Selezionare file txt...');
nomefile=nomefile1(1:end-4);
fid = fopen(nomefile1);

fidw=fopen(strcat(nomefile,'_v2.txt'),'w');

for i_=1:9
line=fgets(fid);
fprintf(fidw,line);
end

fs=prendi_fs(nomefile1);

while ~feof(fid)
line=fgets(fid);
line(1:15)=[' '];
i_=i_+1;
fprintf(fidw,'%s',line);
end

fprintf('Creato nuovo file: %s \r',strcat(nomefile,'_v2.txt'));

fclose(fid);fclose(fidw);
nomefile2=strcat(nomefile,'_v2.txt');

[data, no_el] = importdata_FLF(fs, nomefile2);


C'è per caso una funzione che mi permetta di far eseguire quello che c'è dentro un bottone nella command window?

vpervendetta
18-01-2013, 20:05
E' possibile che debba usare la funzione assignin?