Borrar filtros
Borrar filtros

How can I make a fuction that takes two points and returns the coefficients a, b

3 visualizaciones (últimos 30 días)
How can I make a fuction that takes two points p1 and p2 in 2D plane as input parameters
and returns the coefficients a, b of a linear function f(x) = a*x + b that crosses these points. The points are defined as vectors of two
values: pi =[xi, yi], but without using any ToolBoxes and cycles?
function [a,b] = linfunc(P1, P2)
  1 comentario
David
David el 9 de Dic. de 2022
Editada: Voss el 9 de Dic. de 2022
Hi! This seems like a homework. Anyways, there are some hints:
> You can always get the slope of a line using m = (f(b) - f(a)) / (b - a). Once you get it, your function is almost done!
Good luck <3

Iniciar sesión para comentar.

Respuestas (2)

John D'Errico
John D'Errico el 9 de Dic. de 2022
Surely this is homework. So I hope people do not do your homework for you. At the same time, it is easy to find the formulas online, for example here:

Image Analyst
Image Analyst el 10 de Dic. de 2022
See attached polyfit demo and make the obvious modifications to it to solve your problem.
In the meantime, see polyfit.
This looks like a homework problem. If you have any questions ask your instructor or read the link below to get started:
Obviously we can't give you the full solution because you're not allowed to turn in our code as your own.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by