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 :(

 채택된 답변

the cyclist
the cyclist 2015년 12월 1일
편집: the cyclist 2015년 12월 1일
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

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.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

질문:

2015년 12월 1일

댓글:

2015년 12월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by