Can't run my main Matlab file related to ODE solution

In summary, the conversation is about a person seeking help to spot mistakes in their numerical solution of a diffusivity equation using Matlab. They encounter an error with the command and are unsure of how to interpret it. The conversation also includes the exchange of M files and a link to download a relevant file. The person expresses their frustration and mentions previous unsuccessful attempts to solve the equation.
  • #1
Ein Krieger
34
0
Hey, guys

Can you please help me to spot mistakes in numerical solution of following diffusivty equation:

∂P/∂t= 0.001127*k/(μ*ϕ*c_t )*((∂P/∂x)^2*c+(∂^2 P)/(∂x^2 )).

Matlab give the following command:

Undefined function or variable 'r'.

Error in function_handle2 (line 9)
for i=1:r

Error in odearguments (line 88)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.

Error in ode15s (line 149)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...

Error in Diffusivity_equation (line 41)
[t,p]=ode15s(@function_handle2,tout,p0,options);


I don't know how to interpret the last command. M files containing relevant commands are attached.
 

Attachments

  • Diffusivity_equation.m
    879 bytes · Views: 592
  • function_handle2.m
    479 bytes · Views: 588
Physics news on Phys.org
  • #2
I get an error on line 10 of function_handle2. When I comment it out, I get an error because dss004 is undefined.
 
  • #3
DrClaude said:
I get an error on line 10 of function_handle2. When I comment it out, I get an error because dss004 is undefined.

Hey, mate

You can download dss004 m file from the following link:
https://www.physicsforums.com/showthread.php?p=4292439#post4292439.

I couldn't upload the dss004 file, so decided to redirect you to my previous post where I have already atttached dss004.
 
  • #4
Guys, I need to solve by Matlab the following PDE:
4e5c3bb7979f.png


I am desperate about finding solution; I have tried many approaches, and the files attached on topic start is my last approach.
 
  • #5


Hello,

I'm sorry to hear that you are having trouble running your main Matlab file related to ODE solution. It seems like you are encountering an error message related to an undefined function or variable 'r'. This could be due to a number of reasons, such as a typo in your code or a missing variable declaration.

To help you spot the mistake, I would recommend checking the code for any typos or missing variables. You can also try debugging your code by running it step by step to see where the error occurs.

Additionally, it would be helpful if you could provide more information about your code and the specific error message you are receiving. This will allow me to provide more specific suggestions and assistance.

I hope this helps and good luck with your code!
 

1. Why am I getting an error when trying to run my main Matlab file for ODE solution?

There could be several reasons for this error. Some common causes include syntax errors in your code, missing or incorrect inputs, or issues with your ODE function. Make sure to carefully check your code for any mistakes and review the documentation for the ODE solver you are using.

2. How do I troubleshoot my main Matlab file for ODE solution?

To troubleshoot your code, you can use the debugging tools in Matlab such as breakpoints and the debugger. These tools can help you identify and fix any errors in your code. Additionally, you can also check for any error messages that may provide more information about the issue.

3. Can I use different ODE solvers in my main Matlab file?

Yes, Matlab offers a variety of ODE solvers that can be used in your main file. You can choose the appropriate solver based on the type of ODEs you are solving and the desired accuracy and speed. It is recommended to read the documentation for each solver before using it.

4. How do I specify the initial conditions for my ODE solution in my main Matlab file?

In your main file, you can use the ode45 or ode15s function to specify the initial conditions for your ODE solution. These functions take in the initial conditions as inputs and return the solution vector for the ODEs.

5. Can I plot the results of my ODE solution in my main Matlab file?

Yes, you can use the plot function to plot the results of your ODE solution in your main file. You can also customize the plot by adding labels, titles, and adjusting the axes. This can help you visualize the behavior of your ODEs and make any necessary changes to your code.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • Calculus and Beyond Homework Help
Replies
1
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
6K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Calculus and Beyond Homework Help
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
5K
Back
Top