Matlab error message, help please

In summary, a Matlab error message is a notification that appears when there is a problem with your code or when Matlab is unable to perform a certain task. It can provide information about the nature of the error and where it occurred in your code. You may be getting a Matlab error message due to a mistake in your code, a missing or incorrect input, or a problem with your computer's memory or resources. To read a Matlab error message, you should carefully read and understand the message, check your code and inputs, and search for solutions online. To prevent Matlab error messages, it is important to carefully check and test your code before running it, regularly save your work, and use version control.
  • #1
Daniel1992
22
0
I get this error message

Subscript indices must either be real positive integers or logicals.

Error in doubleODE (line 14)
dYdt(2) = l1*(m1 + m2)*Y(4) - l2*m2*Y(3)*cos(Y(1) - Y(2))/...

I am having trouble working out what is causing the problem. Any advice?

Thanks
 
Physics news on Phys.org
  • #2
It means that you have indices which are not positive integers or logicals so that it chokes on line 14
The actual fault will be before then - without the source code we cannot possibly help.
 
  • #3
I found the error. Turns out I missed a * when multiplying :-|
 
  • #4
Well done.
Amazing what you miss.
 
  • #5
for reaching out for help with this error message. It seems that the issue is related to the indices used in your code. The error message is indicating that the indices must be real positive integers or logicals, meaning they must be whole numbers or true/false values.

To troubleshoot this issue, you can start by checking the values you are using for the indices in line 14. Make sure they are whole numbers and not decimals or fractions. Additionally, check that the values are within the range of the array you are trying to access.

Another possibility is that the indices are not being calculated correctly, which could be due to a mistake in your code. You can try printing out the values of the indices to see if they are being calculated correctly.

If you are still having trouble, you can also try reaching out to the Matlab community for further assistance. They may be able to provide more specific advice based on your code and the error message. Good luck!
 

What is a Matlab error message?

A Matlab error message is a notification that appears when there is a problem with your code or when Matlab is unable to perform a certain task. It can provide information about the nature of the error and where it occurred in your code.

Why am I getting a Matlab error message?

You may be getting a Matlab error message due to a mistake in your code, a missing or incorrect input, or a problem with your computer's memory or resources. It is important to carefully check your code and inputs to identify the source of the error.

How do I read a Matlab error message?

Matlab error messages typically include a short description of the error, followed by a line of code where the error occurred, and sometimes additional information or suggestions for how to resolve the error. Reading and understanding the error message can help you troubleshoot and fix the issue.

What should I do when I encounter a Matlab error message?

When you encounter a Matlab error message, the first step is to carefully read and understand the message. Then, check your code and inputs to identify the source of the error. You may also try searching for the error message online to see if others have encountered a similar issue and how they resolved it.

How do I prevent Matlab error messages?

To prevent Matlab error messages, it is important to carefully check and test your code before running it. This can help identify and fix any errors or bugs before they cause a problem. It is also helpful to regularly save your work and use version control to easily revert back to a previous version if needed.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
805
  • Engineering and Comp Sci Homework Help
Replies
13
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
Replies
2
Views
600
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
15
Views
2K
Replies
12
Views
343
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
Back
Top