Question

In: Electrical Engineering

In MatLab ( this question is after a lecture about GUI ) % How do you...

In MatLab ( this question is after a lecture about GUI )

% How do you read a property from a control (i.e. the
% 'string' property from an edit box)?

Solutions

Expert Solution

follow the following step :

step1 :open gui by typinging guide in matlab command prommt.

step02 :Take one edit box and set its values as shown by clicking on it and i have changed tag property .

step03) now save it and type following command in m file.

function varargout = untitled1(varargin)
% UNTITLED1 MATLAB code for untitled1.fig
% UNTITLED1, by itself, creates a new UNTITLED1 or raises the existing
% singleton*.
%
% H = UNTITLED1 returns the handle to a new UNTITLED1 or the handle to
% the existing singleton*.
%
% UNTITLED1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED1.M with the given input arguments.
%
% UNTITLED1('Property','Value',...) creates a new UNTITLED1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled1_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled1_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help untitled1

% Last Modified by GUIDE v2.5 11-Apr-2018 08:02:05

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled1_OpeningFcn, ...
'gui_OutputFcn', @untitled1_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before untitled1 is made visible.
function untitled1_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to untitled1 (see VARARGIN)

% Choose default command line output for untitled1
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes untitled1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Executes during object creation, after setting all properties.
function edituserinput_CreateFcn(hObject, eventdata, handles)
% hObject handle to edituserinput (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end


function edituserinput_Callback(hObject, eventdata, handles)
% hObject handle to edituserinput (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 edituserinput as text
% str2double(get(hObject,'String')) returns contents of edituserinput as a double

%below two lines are very important

%line one reads the string data type from user

%line2 store that data from variable userinput in gui to variable name userdata in matlab workspace

userinput=get(handles.edituserinput,'string');
assignin('base','userdata',userinput);

RESULT:

I have typed hi .

Note you get variable named userdata having string hi stored in workspace.


Related Solutions

How do you feel about the question, "is it legal to lie?" Do you agree or...
How do you feel about the question, "is it legal to lie?" Do you agree or disagree with the statement? Give an explanation for your answer using evidence.
Please answer this question in details . this lecture is about The master budget is a...
Please answer this question in details . this lecture is about The master budget is a picture of the strategic plan’s projected results in financial terms. you will learn the purpose of the master budget and how it is compiled from functional area budgets within an organization. In different textbooks praise the benefits of participative budgeting. Is it wise to involve multiple parties at multiple levels in the organization in the budget preparation process? Why or why not? Embed course...
how do you demonstrate convultional and clock interleaving matlab?
how do you demonstrate convultional and clock interleaving matlab?
MATLAB question: how do you write a video file using videowriter without displaying the current figure...
MATLAB question: how do you write a video file using videowriter without displaying the current figure when doing getframe? I want to go through the data packet Xpixels x Ypixels x Zframes for each frame and write it to a video without showing the display until it's finally done. also I noticed if I turn the figure off the code runs much much slower using fig = figure(visible off). is there anyway to avoid this sluggishness? and speed it up...
I need an original matlab code and gui for a simple double pendulum. This needs to...
I need an original matlab code and gui for a simple double pendulum. This needs to be original and not too complicated. Please provide basic instructions. Thank you!
Using matlab: Build a graphical user interface (GUI) the will read the two corners of a...
Using matlab: Build a graphical user interface (GUI) the will read the two corners of a rectangle (from the GUI interface) and show the following: A plot of the rectangle (you should have display for it) Show the centroid (the center of the rectangle) on the graph. Calculate the area and the circumference of the triangle (you need to write a function for that). The interface should have at least the following: Four textboxes to read the ( 2 for...
solve any question about fourier series by using MATLAB
solve any question about fourier series by using MATLAB
answer the question after reading the short article. Question: Do you think that are the bouquets...
answer the question after reading the short article. Question: Do you think that are the bouquets given away for free a public good? Free Flowers Are Being Given Away in Downtown Crossing The Society of American Florists wants to 'petal it forward' on Wednesday. by MADELINE BILIS· 10/18/2016, 10:18 a.m. Photo by the Massachusetts Office of Travel and Tourism on Flickr/Creative Commons Stroll down the pedestrian. walkway in Downtown Crossing on Wednesday and there’s good chance you’ll be surprised with...
how do you restore homeostasis of the nervous system after a stroke? how do you restore...
how do you restore homeostasis of the nervous system after a stroke? how do you restore homestasis of the endocrine system after a stroke? sentences please.
In reference to the lecture we had about the yield curve, the lecture note and the...
In reference to the lecture we had about the yield curve, the lecture note and the video posted in the topic 1 folder in the Course materials, discuss: 1. What is inverted yield curve? (2 points) 2. Why is it interpreted as the sign of imminent recession? (4 points) 3. What causes the inverted yield curve? (4 points) It is absolutely crucial to provide the logical reasoning & the schematic account of the financial market process.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT