How to make function that goes between points

Hello,
so I have data from excel for Y and X, but I can't figure out how to make plot that will show me function that goes between points from data. Can someone help?
Thanks to all that want to help

7 commentaires

Torsten
Torsten le 27 Jan 2024
Modifié(e) : Torsten le 27 Jan 2024
What do you want ? The equation of a function that passes through all your (X,Y) points ? A function that approximates your function ?
Try
help polyfit
help fit
Sam Chak
Sam Chak le 27 Jan 2024
Hi @Marcin, let me try to paraphrase your message using the "New Math Translation (NMT)". Please correct me if I misunderstood your original intent.
Hi Guys,
I have a set of data points from an Excel file, with corresponding X and Y values. I'm looking for assistance in creating a plot that accurately represents the relationship between these data points using a mathematical function.
I'm unsure of how to proceed with plotting the function that connects the data points. Could someone please provide guidance or help me with this?
Thank you in advance for your assistance!
Marcin
Marcin le 27 Jan 2024
My problem is, that this one I can somehow even find in internet but my intent is diffrent. I want this function to not connect with any of this point. It should go this way, that about half points will be above function and other half will be below it.
I think this is called aproximation function, but I couldn't find any tutorial that will show me how to do it. My problem is too that I don't have any function formula given in my exercise and most tutorials show codes that are based on some function formula.
It should look something like in this random picture that I linked.
Torsten
Torsten le 27 Jan 2024
Read the documentation of MATLAB's "fit" function. It offers the possibility to choose between different function types (polynomials, exponential functions, sin/cos- expressions,...) to best-approximate your data.
Marcin
Marcin le 27 Jan 2024
Thank you. I will read it now.
Sam Chak
Sam Chak le 27 Jan 2024
If my guess is correct, RBFN stands for Radial Basis Functions Network. In essence, the RBFN model is used to fit the data, and it likely consists of numerous nodes and layers, making it challenging to express the model as a elegant analytical function, like an exponentially-growing sinusoidal signal (<-- keywords).
John D'Errico
John D'Errico le 27 Jan 2024
Modifié(e) : John D'Errico le 27 Jan 2024
There are many possible errors you will make, if all you do is try to use a tool like polyfit, or for that matter, any modeling tool. And since we do not see your data, we cannot know which of those failure modes you will most probably trip upon. This will be a learning experience for you. You can do a lot of reading, but even then, reading will not give you the knowledge you will need to make the decisions about which model might be best to use. The point being, it would help if you post your real data. Not fake data. That way we can advise you better in a choice of model.
As well, you need to know what you want from that model. Do you simply want a pretty picture of a curve drawn through the data? Will you want to write the actual model down, in a report, your homework assignment, or a paper? What will you be using the model for? What do you know about the data? What information, if any, do you have about any properties that are necessary in the resultant model? Must the curve pass through the origin, for example? Must it be monotonic to make physical sense?
All of these things and more are important in your choice of a model form. The more and better information you can provide, the better an answer someone can offer to you.

Connectez-vous pour commenter.

Réponses (1)

Image Analyst
Image Analyst le 27 Jan 2024

0 votes

Try readmatrix or readtable to read your data from the Excel file into MATLAB.
To fit a smooth curve through the data, if it's a polynomial, you can see my attached demo.
If you have some non-linear model in mind, see fitnlm. See attached fitnlm demos.
Use linspace to make your x values. Then use plot to plot your smoothed y values vs. x.

Community Treasure Hunt

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

Start Hunting!

Translated by