MATLAB Answers

how to write in edit field

5 views (last 30 days)
naouras saleh
naouras saleh on 4 Nov 2019
Commented: naouras saleh on 6 Nov 2019
hello
i'm new to matlab can you help me
in app designer i want to write ip address in edit field
here is the showen function, what i have to write inside it?
function CameraIPEditFieldValueChanged(app, event)
end
thank you

  0 Comments

Sign in to comment.

Accepted Answer

Katie
Katie on 4 Nov 2019
Hi! What you're showing in your question is the callback function for the CamperaIP edit field. This function is called whenever you type something new into that edit field while running your app. If you're interested in storing whatever you type into this field for use in other parts of the app, you could have a property (for example, let's call the property "CameraIP") that you store the edit field value in. Then in the callback function you are showing, you could do the following:
function CameraIPEditFieldValueChanged(app, event)
app.CameraIP=app.CameraIPEditField.Value;
end
In this function, the property "CameraIP" will get updated anytime you type something new into this edit field. Then in other places throughout the app, you can reference app.CameraIP to use whatever value is stored in this property.
If you want to have a starting IP address in that edit field, in your startupFcn callback you could do the following:
function startupFcn(app)
app.CameraIPEditField.value='0.000.00.000';%enter whatever IP address you want here
end
Whenever you run the app, your edit field will start out filled with this IP address.
If you're having trouble writing new values to this edit field, make sure the edit field component is set as "editable." You can field this option in the Component Browser in the Design View within app designer.
Hope this helps!

  3 Comments

naouras saleh
naouras saleh on 5 Nov 2019
thank you very much for your helping.
i have another question if u can help me out with it:
i have created editable uitable with this code:
app.UITable.ColumnName={'position 1'; 'position 2 '; 'position 3 '; 'position 4 '};
t = app.UITable;
set(t,'data',ones(25,4))
set(t,'ColumnWidth',{100})
set(t,'ColumnEditable',logical([1 1 1 1]))
app.cameraIPEditField.Value='0.0000.00.000';
app.RobotIPEditField.Value='0.0000.00.000';
and when i press puch button it will save the table content with this code:
function EntreButtonPushed(app, event)
t = app.UITable;
l= get(t, 'data');
xlswrite('sasa', l);
end
my question is how can i write string in the uitable when i try to add it shows NAN ?
2- how can i save the colume name in the file ?
thank you very much
Katie
Katie on 6 Nov 2019
Hi, it looks like when you're initializing your table you're setting all the entries (25 rows by 4 columns) to be 1. This is setting the data type of all the columns to be double. You could initialize the column or rows you want to be strings by using cells. As an example to set the first row of your table to use different data types, you could do the following:
app.UITable.Data{1,:}={1,' ',0,' '};
This would make the first column be of data type double, the second column be for strings, the third for doubles, and the fourth for strings.
You can pull the column names using:
colnames=get(handles.UITable,'columnname')
Than you could put the variables colnames and l together in a cell array and then write the cell array to a file.
naouras saleh
naouras saleh on 6 Nov 2019
Thank you so much I really appreciate it. You helped me alot Now I have better understanding.

Sign in to comment.

More Answers (1)

Ajay Kumar
Ajay Kumar on 4 Nov 2019
doc uieditfield

  0 Comments

Sign in to comment.

Sign in to answer this question.