- Typically, "X" is a design matrix of predictor (independent variable) values, with one row for each value in "Y", and one column for each predictor.
- "Y" for fitting the nonlinear regression function, specified as a vector with the same number of rows as "X".
How can I adjust the output of my pdepe function for nlinfit?
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi!
I have the following system of coupled PDEs which I have solved using the pdepe solver. I have compared it to an analytical solution and verified it. Now I am trying to fit some experimental data to this system. I am using the nlinfit function to do achieve this.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/982595/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/982600/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/982605/image.png)
After that I calculate the flux
using pdeval to use in below expression. I am using the final row of the solution BTW so basically
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/982635/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/982640/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/982645/image.png)
And thus finally I get my
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/982650/image.png)
Now I guess the problem here is that I am unable to compute the necessary number of solutions for
or I_num as it is referred to in the code.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/982655/image.png)
As I am getting the following error.
Error using nlinfit (line 219)
MODELFUN must be a function that returns a vector of fitted values the same size as Y (6-by-1). The model function you provided returned a result that was 1-by-1.
One common reason for a size mismatch is using matrix operators (*, /, ^) in your function instead of the corresponding elementwise operators (.*, ./, .^).
Error in PSw_EK_v4_Caller (line 26)
[beeta] = nlinfit(alphaa,I_exp,@PSt_EK_v4,beta0);
I am calling the pdepe using the following script.
I_exp = [2.5e-03;
2.8e-04;
2.5e-03;
2.8e-04;
2.5e-03;
2.8e-04];
alphaa = [5.00000000000000e-06,3.46000000000000e-06,3.54444000000000e-07;
5.00000000000000e-06,3.46000000000000e-06,3.54444000000000e-07;
5.00000000000000e-06,3.46000000000000e-06,3.54444000000000e-07;
5.00000000000000e-06,3.46000000000000e-06,3.54444000000000e-07;
5.00000000000000e-06,3.46000000000000e-06,3.54444000000000e-07;
5.00000000000000e-06,3.46000000000000e-06,3.54444000000000e-07];
% wrapper = @(beeta, alphaa)arrayfun(@(si)PSt_EK_v4(beeta,si), alphaa);
beta0 = [5e-06; 0; 2.81E-06; 800; 1e-05; 1e05]; % starting point
[beeta] = nlinfit(alphaa,I_exp,@PSt_EK_v4,beta0);
댓글 수: 0
답변 (1개)
SAI SRUJAN
2023년 10월 11일
Hi Hashim,
I understand that you are facing an issue using the "nlinfit" MATLAB function.
Based on the error message, "PSt_EK_v4" must be a function that returns a vector of fitted values the same size as "I_exp" (6-by-1). The model function you provided returned a result that was 1-by-1.This mismatch of dimensions is leading to the error.
Furthermore, the function "nlinfit" has specific conditions that need to be met by the input parameters.
For a comprehensive understanding of the "nlinfit" function in MATLAB, please refer to the provided documentation below.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!