필터 지우기
필터 지우기

Accelerometer data MatLab GUI

조회 수: 1 (최근 30일)
Amed
Amed 2013년 2월 1일
답변: ASHISHREDDY THUMMALA 2019년 4월 14일
Hello i'm trying to read in raw data from an accelerometer thru my matlab GUI. I have a pushbutton for serial read, calibration, and port closing that all work fine but i'm trying to create a button that will read in raw data from the accelerometer port.
% START DATA - PUSHBUTTON6
function pushbutton6_Callback(hObject, eventdata, handles)
function [gx gy gz] = readAcc(out,calCo)
%mapping between analog inputs and X,Y,Z axes.
% Xch = 1;
% Ych = 3;
% Zch = 2;
fprintf(out.s,'R');
%read voltages from accelerometer and reorder
reordered(1)= fscanf(out.s,'%u');
reordered(2)= fscanf(out.s,'%u');
reordered(3)= fscanf(out.s,'%u');
%determine what offset and gain values to use
offset = calCo.offset;
gain = calCo.g;
accel = (reordered - offset) ./ gain;
%map analog inputs to axes
gx = accel(1);
gy = accel(2);
gz = accel(3);
end
guidata(hObject, handles);
The error i'm getting is
Error: File: BW2.m Line: 161 Column: 1 The function "readAcc" was closed with an 'end', but at least one other function definition was not. To avoid confusion when using nested functions, it is illegal to use both conventions in the same file.
even if I delete the bottom 'end' function, I press the pushbutton and nothing reads out.
  댓글 수: 9
Amed
Amed 2013년 2월 1일
편집: Amed 2013년 2월 1일
I'm confused sorry, but what is my current out.s?
edit: I have this in my openingfnc guidata(hObject, handles); handles.out = out.s; handles.gx= 0; handles.gy= 0;
and recieved this error Undefined variable "out" or class "out.s".
Error in BW2>BW2_OpeningFcn (line 61) handles.out = out.s;
Error in gui_mainfcn (line 221) feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});
Error in BW2 (line 42) gui_mainfcn(gui_State, varargin{:});
>>
Daniell Algar
Daniell Algar 2013년 2월 1일
Yes, it's the same problem as my last comment......
If you yourself do not know what out.s is, I cant help you. I guess it's the output from you sensor...

댓글을 달려면 로그인하십시오.

답변 (1개)

ASHISHREDDY THUMMALA
ASHISHREDDY THUMMALA 2019년 4월 14일
You have declared 2 functions in your script, then you should have end for both functions. That means two end's
What accelerometer are you using ?

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by