Home > Blockchain >  My function wont Plot for an array of variables
My function wont Plot for an array of variables

Time:12-11

I am trying to plot a graph for the Voltage/resistance Relationship of a Quarter-bridge Wheatstone bridge, so that i can compare it to my actual values. The code is as follows:

Vin = 3.3; %Voltage input
DR = 0.19*10^3:0.01*10^3:0.30*10^3; % Change in resistance due to stretch sensor
R0 = 1.3*10^3; % Initial resistance of other 3 resistors
R= R0 DR;

VQB = (DR/((4*R0) (2*DR)))*Vin;  % General Quarter Bridge Equation

vout = 6.8*VQB; % Amplified Output voltage

plot(R,vout); hold on

Im not sure why but i get no data in the plot, i have used the function just like this before where i have an array of incrementing data being pumped into an equation to generate an output. But this time it only gives a single data point. What's going wrong?

CodePudding user response:

Put a point just after DR in VQB to compute the VQB for all components of DR:

Vin = 3.3; %Voltage input

DR = 0.19*10^3:0.01*10^3:0.30*10^3; % Change in resistance due to stretch sensor
R0 = 1.3*10^3; % Initial resistance of other 3 resistors
R= R0 DR;

VQB = (DR./((4*R0) (2*DR)))*Vin;  % General Quarter Bridge Equation

vout = 6.8*VQB; % Amplified Output voltage
figure(1), hold on;
plot(R,vout); 
xlabel('R')
ylabel('vout')

CodePudding user response:

Add a point also before ^ where you raise to a power

DR = 0.19*10.^3:0.01*10.^3:0.30*10.^3; % Change in resistance due to stretch sensor
R0 = 1.3*10.^3; % Initial resistance of other 3 resistors

VQB = (DR./((4*R0) (2*DR)))*Vin;

Should work now

  • Related