Hi,
Looking for help on what is probably an easy problem. I can't even get data into Matlab correctly to start!
I have MS Excel grid - temperature (orange), %alcohol (blue), density (green). This is excerpt:
I would like to create a function/formula: input density and temperature, output %alcohol. This function should interpolate/extrapolate, so for example could enter temperatures like 34.6, 40.7
So guess I would like to fit a surface and get function equation, and then reorganize so %alcohol is on LHS.
Questions:
1. First problem how to import data into grid format I can use? I have tried to bring in as table, but treats every column as different variable.
2. How to best fit a function to this data and "solve" for %alcohol.
Any suggestions, similar examples, outline workflows appreciated.
Thanks, Michael

 채택된 답변

Walter Roberson
Walter Roberson 2018년 9월 4일

0 개 추천

data = xlsread('YourFile.xlsx');
alch = data(2:end,1);
temperature = data(1,2:end);
density = data(2:end,2:end);
surf(temperature, alch, density, 'edgecolor','none')
xlabel('temperature'); ylabel('% alcohol')

댓글 수: 1

Michael Cody
Michael Cody 2018년 9월 5일
Hi Walter, This is nice succinct answer to my question on how to order data for 3D surface. Obvious of course, when someone shows you!
I think will close this question now and split my second question into a new thread after I do some more research.
Thanks a lot. Michael

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

추가 답변 (1개)

ahmed nebli
ahmed nebli 2018년 9월 2일

0 개 추천

1- u need to use the function xlsread , see this link : https://www.mathworks.com/help/matlab/ref/xlsread.html

댓글 수: 3

Michael Cody
Michael Cody 2018년 9월 3일
Hi Ahmed,
Thanks for answer. With this function can import row, columns, ranges etc. But can't figure out how to organize variables so could use surf function, for example. Data dimensions must agree.
Can you give me any further suggestions?
Thanks, Michael
ahmed nebli
ahmed nebli 2018년 9월 3일
i think once you imported the xls sheet, u need to store it in a .mat file , then you can treat the double sttored in the .mat like you want
Loaded data, each set into own variable matrix. My main problem was how to organize data for 3D plot and curve fitting.
I eventually found meshgrid which seemed to help me.
[abv_x,temperature_y] = meshgrid(abv,temperature)
surf (abv_x,temperature_y,density)
Thanks for tip on xlsread.
On question 2, if I fit with interpolation curve then seems cannot evaluate for points outside original data range e.g my max temperature is 40, if try feval on fit function get NaN. Is this limitation of interpolation do you know?
Thanks, Michael

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

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

제품

릴리스

R2014a

질문:

2018년 9월 2일

댓글:

2018년 9월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by