Calculate multivariable equation with Matlab

1 view (last 30 days)
Daniel
Daniel on 14 May 2023
Answered: Catalytic on 14 May 2023
I am trying to calculate the voltage of a circuit with an ADC, the problem is that I am seeing that the voltage reading has to be done from a function and that it depends on the current of the circuit, I arrived at the following equations for 0A, 0.4 A and 1.1A:
0A: 0.10680454x - 7.6688459
0.4A: 0.10669344x - 13.84042838
1.1A: 0.10652463x - 24.9126498
How can I put this together into an equation with two variables One for the voltage reading and one for the amperage.
Thank you so much!
Here is a plot of how the amperaje affects the votlage reading

Answers (1)

Catalytic
Catalytic on 14 May 2023
You need some sort of model for the line slopes and intercepts as a function of the amperage. There are infinitely many that can be proposed. For example -
x0=[0,0.4,1.1];
y0=[0.10680454 0.10680454 0.10652463;
7.6688459 13.84042838 24.9126498];
voltage=@(A,x) voltageFcn(A,x, x0,y0);
function v=voltageFcn(A,x, x0,y0)
p=spline(x0,y0,A);
v=p(1)*x+p(2);
end

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!