Trying to plot a simple linear function but returns constant

Hi! I'm working on a temperature sensor and I've found its equations on this link: PT-100. It's a device which electric resistance depends on temperature changes and it can be easily measure with a voltage output when it's apply on a bridge circuit.
But in general the code is the next:
clear all
close all
clc
T = 0: 0.01 : 200;
alpha = 0.00385;
R0 = 100;
RT = R0 * (1 + (alpha * T)); % ............(1)
V_cd = 5;
Voltage = ((RT/(RT + R0)) - 0.5)*5; % ..........(2)
subplot(2,1,1)
plot(T,RT)
ylabel('Resistance');
xlabel('Temperature °C');
grid on;
subplot(2,1,2)
plot(T,Voltage);
ylabel('Voltage');
xlabel('Temperature °C');
grid on;
(1) and (2) are the functions that I'm trying to plot, RT (1) is a function that depends on temperature changes T = 0:0.01:200 -> °C, and Voltage depends on RT output. When I plot RT vs T it returns a linear function on a graph, but when I plot Voltage vs T it returns a constant!!
I think I'm doing something stupid but I can't find the problem hahahah I always use matlab for modeling electronics but it's the first time I got a plotting problem with matlab :(

 Respuesta aceptada

the cyclist
the cyclist el 1 de Dic. de 2015
Editada: the cyclist el 1 de Dic. de 2015
You were accidentally doing a matrix division, instead of element-wise division. Try this instead:
Voltage = ((RT./(RT + R0)) - 0.5)*5; % ..........(2)
Notice the "./" in place of just "/".

2 comentarios

wow! It's solved! thanks a lot cyclist! Now I'm interested on this "./" what is it? I'll search about it! seriously thanks :)
An important thing to remember is that MATLAB has a strong emphasis on matrix operations, from its original on linear algebra. So "*" and "/" are matrix operators, which can surprise new users.
Here is one documentation page that discusses array vs matrix operations.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 1 de Dic. de 2015

Comentada:

el 1 de Dic. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by