Hi ... so i need to do currency exchanger with GUI .... basically my teacher say she wants to be a euro to other 5 currencies . So lets say she wants to convert 3 euro to mexiacan pesos the result will pop up in msg box ... I have started with it but something is not working. If somebody can help me i would be very happy ... This is what I've got so far ... i just need a help with one the other currencies are just a work of changing numbers.
% --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % 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)
val1=get(handles.popupmenu1,'Value');
if val1==1
val1=0.0508
m=str2num(get(handles.edit1,'String'));
b=m*val1;
msgbox(b)
end

2 Kommentare

Image Analyst
Image Analyst am 30 Apr. 2016
You'll probably need webread() to download the latest currency exchange rates from the web.
"something is not working" is not very specific. Explain exactly what you see, or post all the red error text that you see in the command window.
Luke Libovic
Luke Libovic am 1 Mai 2016
Bearbeitet: Geoff Hayes am 1 Mai 2016
when i click run this pops up ... the whole file is named premeny_mien .. just to be clear
>> premeny_mien
val1 =
0.0508
Error using dialogCellstrHelper
Expected input to be one of these types:
char, cell
Instead its type was double.
Error in dialogCellstrHelper (line 10)
validateattributes(inputStr, {'char','cell'}, {'2d'},mfilename);
Error in msgbox (line 62)
BodyTextString = dialogCellstrHelper(inputStr);
Error in premeny_mien>pushbutton1_Callback (line 132)
msgbox(b)
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in premeny_mien (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)premeny_mien('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Geoff Hayes
Geoff Hayes am 1 Mai 2016

1 Stimme

Luke - according to msgbox, the input to this function must be a character array or a cell array go strings. Given your code
b=m*val1;
msgbox(b)
you are trying to pass in a double. If you want to display this value in a message box, you need to convert it to a string. You can do this in one of two ways
msgbox(num2str(b));
or
msgbox(fprintf('%f',b));

1 Kommentar

Luke Libovic
Luke Libovic am 1 Mai 2016
Thank you so much ... you helped a lot :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by