0
votes

I am building a matlab GUI to retrieve an average PnL number from a 1047*1 double cell string called pnl_P1 into edit text window called (function Average_PnL_Pair_1_Callback(hObject, eventdata, handles)). What is the simplest or very simple way to do this?

2
Can you post an example of the input data?Nzbuu
in function Start_visualization_button_Callback(hObject, eventdata, handles)...i have the following....cumi_P1 = evalin('base', 'cumi_P1'); axes(handles.PnL_Pair_1_axes) plot('cumi_P1, 'DisplayName', 'cumi_P1', 'YDataSource', 'cumi_P1'); guidata(hObject, handles); then in the axis....function Period_PnL_Pair_1_Callback(hObject, eventdata, handles) % handles structure with handles and user data (see GUIDATA) cumi_P1 = evalin('base','cumi_P1'); plot(cumi_P1) guidata(hObject, handles); %updates the handles .....how can import this cumi_P1 from workspace and get the axis to plot it? input.d 1047*1Noob_1

2 Answers

1
votes

Do you want mean(cellfun(@str2double, pnl_P1))?

1
votes

If I understand your problem correctly I'd do the following.

Do not store numbers in cell string array, but if you must, use mean(cell2mat(pnl_P1)) to get the mean value. Create a value under handles so you can reach your pnl_P1 vector from anywhere.

handles.pnl_P1 = pnl_P1;

Make sure you always update your handles after each function in your GUI. It is strongly recommended. % Update handles structure

guidata(hObject, handles);


Insert value into edit box:

set(handles.edit1,'String',mean(cell2mat(handles.pnl_P1)));

handles.edit1 is the tag handle for the edit box you want to update.

What is the tag for your edit box? Simple: in guide right-click on your edit box, select properties inspector, scroll down to Tag. If it says edit1 then use handles.edit1 and so on.

If you are new to Matlab GUIs I recommend this. They have stopped updating it but it's a great learning source.

I hope this helps.