How to pass string value from one callback function to another?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
採用された回答
20 件のコメント
% --- Executes on button press in pushbutton7. function pushbutton7_Callback(hObject, eventdata, handles)
[filename,filepath]= uigetfile({'*.*';'*.wav';'*.m4a'});
fullname = fullfile(filepath, filename);
set(handles.edit6,'string', fullname);
% --- Executes on button press in button. function button_Callback(hObject, eventdata, handles) % hObject handle to button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
fullname = get(handles.edit6, 'string');
data = audioread(fullname);
L= length (data);
Y= fft(data)
P2= abs (Y/L)
P1= P2(1:L/23+1);
P1(2:end-1)= 2*P1(2:end-1)
figure= subplot('position', [0.56, 0.15, 0.4, 0.3]);
K= plot (P1);
title ('Frequency Domain')
xlabel('f(Hz)')
ylabel('P1(f)')
hold on
[y,Fs]= audioread(fullname); t= linspace(0,length(y)/Fs, length(y));
figure1= subplot('position', [0.10, 0.15, 0.4, 0.3]);
plot(t,y);
title ('Time Domain')
xlabel('Time (sec)')
ylabel('Amplitude')
I am having a problem. when i get the back button in this .fig and come back and try to browse the .wav file, it does not set the fullname in the edit text box.
Put in a breakpoint at the uigetfile and step through to see what happens. For example is handles.edit6 still a valid handle at the time of the set() ? If the set() works without error then what do you get if you then (in the debugger)
get(handles.edit6, 'string')
this is error the message that I am getting..
Undefined function or variable 'button_DeleteFcn'.
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in multiply (line 43)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)multiply('button_DeleteFcn',hObject,eventdata,guidata(hObject))
Error using multiply>figure1_CloseRequestFcn (line 140) Error while evaluating UIControl DeleteFcn.
Dot indexing is not supported for variables of this type.
Error in multiply>pushbutton7_Callback (line 248) set(handles.edit6,'string', fullname);
Your uicontrol named button with string Train! has been configured to expect to be able to call button_DeleteFcn and button_KeyPressFcn but those do not exist.
Please make sure you are using my versions of the .fig and the .m . Close any existing figures and "clearvars"
The fix for the back button (which has already been written into that multipy.m) was
function pushbutton2_Callback(hObject, eventdata, handles)
back_to = 'SRS01_GUI_TrainPage.fig';
if exist(back_to, 'file')
open(back_to);
close('multiply');
else
waitfor(warndlg( sprintf('Cannot go back, did not find find "%s"', back_to)));
end
That is, the reason you were failing was that the "back" button was trying to invoke SRS01_GUI_TrainPage and that did not exist. The replacement code makes sure it exists before trying to invoke it.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Code Execution についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
