i am taking 3 input sensor values from the arduino. i want to plot these values in 3 different axes created in matlab guide.these plot should be in real time.how can i get the sensor data separetely.i treid to write code for single sensor here is the code
function varargout = vvx(varargin)% VVX M-file for vvx.fig
% VVX, by itself, creates a new VVX or raises the existing
% singleton*.
%
% H = VVX returns the handle to a new VVX or the handle to
% the existing singleton*.
%% VVX('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in VVX.M with the given input arguments.
%% VVX('Property','Value',...) creates a new VVX or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before vvx_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to vvx_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 vvx
% Last Modified by GUIDE v2.5 02-Apr-2015 18:56:28
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @vvx_OpeningFcn, ... 'gui_OutputFcn', @vvx_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif 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 vvx is made visible.
function vvx_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 vvx (see VARARGIN)
% Choose default command line output for vvx
handles.output = hObject;% Update handles structure
guidata(hObject, handles);% UIWAIT makes vvx wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = vvx_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structure
varargout{1} = handles.output;% --- Executes on button press in start.
function start_Callback(hObject, eventdata, handles)% hObject handle to start (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)obj = serial('COM17'); %creating the object
set(obj,'BaudRate',9600) %setting baudrate
fopen(obj); %open port
set(obj,'terminator','cr') %providing the terminator
pressure1=0; % a variable for y axis
time1=now; % time is in x axis
while 2>1 time2=now; x=[time1 time2]; pressure2 = fscanf(obj) ; pressure=[pressure1 pressure2]; if (pressure>200)&(pressure<500) set(handles,'XData','g',[get(handles,'XData') x]); set(handles,'YData','g',[get(handles,'YData') a]); else if (pressure >300)&(pressure<700) set(handles,'XData','o',[get(handles,'XData') x]); set(handles,'YData','o',[get(handles,'YData') a]) else set(handles,'XData','r',[get(handles,'XData') x]); set(handles,'YData','r',[get(handles,'YData') a]) end end set(handles.uitable1, 'data', a2); drawnow; datetick('x','HH:MM') %change the axis
pause(0.5); pressure1=pressure2; time1=time2; end
Best Answer