I need to plot a graph of P, Rdia and Vo, please help me how to get graph. (for every 10 increment of pressure, there is 1 ohm increment of Rdia , and display the output vo)

조회 수: 5 (최근 30일)
Rdia = 3673; % dia resistance value in ohm ;
Rtemp = 3618; % Temperature resistance value in ohm;
R1 = 3600; % fixed resistance in ohm;
R2 = 3600; % fixed resistance in ohm;
Rof1 = 150; % offset compensation resistance in ohm;
Rof2 = 200; % offset compensation resistance in ohm;
Vexc = 0.748; % excitation voltage;
for P = 0:10:300 % pressure increment to 10 mmHg
P
for m =1
if (P == 0)
Rdia_new = Rdia
x = Rdia_new/(Rdia_new+R1);
y = (Rtemp+Rof1)/((Rtemp+Rof1) + (R2+Rof2));
vo = ((x - y)*Vexc)*1000; % output voltage in volts
disp(vo)
else
Rdia_new = Rdia+m
Rdia =Rdia+1;
x = Rdia_new/(Rdia_new+R1);
y = (Rtemp+Rof1)/((Rtemp+Rof1) + (R2+Rof2));
vo = ((x - y)*Vexc)*1000;
disp(vo);
end
end
end

채택된 답변

VBBV
VBBV 2022년 4월 22일
Rdia = 3673; % dia resistance value in ohm ;
Rtemp = 3618; % Temperature resistance value in ohm;
R1 = 3600; % fixed resistance in ohm;
R2 = 3600; % fixed resistance in ohm;
Rof1 = 150; % offset compensation resistance in ohm;
Rof2 = 200; % offset compensation resistance in ohm;
Vexc = 0.748; % excitation voltage;
I = 1;
m = 1;
for P = 0:10:300 % pressure increment to 10 mmHg
P;
if (P == 0)
Rdia_new(I) = Rdia;
x = Rdia_new/(Rdia_new+R1);
y = (Rtemp+Rof1)/((Rtemp+Rof1) + (R2+Rof2));
vo(I) = ((x - y)*Vexc)*1000; % output voltage in volts
% disp(vo);
else
Rdia_new(I) = Rdia+m;
Rdia =Rdia+1;
x = Rdia_new/(Rdia_new+R1);
y = (Rtemp+Rof1)/((Rtemp+Rof1) + (R2+Rof2));
vo(I) = ((x - y)*Vexc)*1000;
%disp(vo);
end
I = I+1;
end
P = 0:10:300 ;
subplot(211)
plot(P,vo);
subplot(212)
plot(P,Rdia_new)
  댓글 수: 3
VBBV
VBBV 2022년 4월 22일
use clear at beginning of code and run it. Everytime you run, data for variables is created in workspace
clearvars
%or
clear

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by