How can I open a document (Excel) from my Edit Box in Matlab GUI?

4 ビュー (過去 30 日間)
Black4Ghost
Black4Ghost 2019 年 11 月 28 日
編集済み: Rahul 2025 年 2 月 19 日 9:33
As statted in the title I dont know how to let matlab follow a hyperlink that is written in the edit box from my gui. Is there a special command except uigetdir and uigetfile?
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(~, ~, ~)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% figure;
% t = 0:0.1:2*pi;
% x = cos(t); y = sin(t);
% plot(x, y, 'r');
% axis equal;
%[v,~,~]=xlsread('Test für Azubi.xlsx'); %Auswahl der Datei
v=edit1;
w=v(:,2);
x=v(:,3);
y=v(:,4);
z=v(:,5); %Zuordnung von den Columns zu variablen
plot(w); %Darstellen von CellA
hold on; %ermöglichen von vermehrter Darstellung von Werten auf y Achse
plot(x); %Darstellen von Max_Li
plot(y); %Darstellen von Max_Re
yyaxis right; %Rechte Achse mit Batterie Spannung
z=v(:,5); %Vorgabe der Daten für rechte y Achse
plot(z); %Darstellen von CellV
hold off
function edit1_Callback(~, ~, ~)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
edit1 = uigetdir;

回答 (1 件)

Rahul
Rahul 2025 年 2 月 19 日 9:33
編集済み: Rahul 2025 年 2 月 19 日 9:33
To open a document from the edit field text in MATLAB GUI, consider using the function 'web'. Here is an example:
function ButtonPushed(app, event)
url = app.edit1.Value;
if ~isempty(url)
% Opens the URL in the default web browser
web(url, '-browser');
end
end
The following MATLAB Answers can be referred:
The following MathWorks documentation cen be referred to know more:
Thanks.

カテゴリ

Help Center および File ExchangeCall Web Services from MATLAB Using HTTP についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by