Borrar filtros
Borrar filtros

Incorrect subtraction value in Matlab GUI

3 visualizaciones (últimos 30 días)
Matuno
Matuno el 29 de Dic. de 2013
Respondida: Azzi Abdelmalek el 29 de Dic. de 2013
I am working with COM port and I am getting a value (e.g. temperature value) from COM. Now when I am trying to subtract a specific value (e.g. 8) from this value it is not showing desired value. Here is the code:
function pushbutton1_Callback(hObject, eventdata, handles)
instrreset; %resets the serial devices
clc;
s = serial ('COM6');
RxText3 = fscanf(handles.serConn);
key = 8;
P = minus(RxText3,key);
set(handles.tempserial,'string',P);
fclose(s);
What I am expecting: Suppose I am getting a value as 32 and my key value is 8. Then I am expecting to get 24.
What I am getting: I am getting two values as 42 and 45.
Additional problem:
How can I set the value so that it would show 24 Celcius? I tried this : set(handles.tempserial,'string',P, 'Celcius') in which case nothing is shown.

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 29 de Dic. de 2013
Maybe you need to convert from string to double
P = minus(str2num(RxText3),key);

Más respuestas (0)

Categorías

Más información sobre Use COM Objects in MATLAB en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by