Error on mathlab, and I have no idea how to correct it, me out

Click For Summary
SUMMARY

The discussion centers around a MATLAB error encountered during a class assignment. The specific error message indicates that the inputs to the power function must be a scalar and a square matrix. The solution provided involves modifying the function to use exp() instead of the incorrect usage of e. This adjustment resolves the error and allows the code to execute correctly.

PREREQUISITES
  • Understanding of MATLAB syntax and functions
  • Familiarity with mathematical operations in programming
  • Knowledge of function handles in MATLAB
  • Basic troubleshooting skills in coding
NEXT STEPS
  • Learn about MATLAB function handles and their usage
  • Explore MATLAB error handling techniques
  • Study the differences between scalar and matrix operations in MATLAB
  • Investigate the use of built-in mathematical functions in MATLAB
USEFUL FOR

Students, educators, and developers working with MATLAB who are troubleshooting code errors or learning to implement mathematical functions in their assignments.

vienhuynh
Messages
2
Reaction score
0
error on mathlab, and I have no idea how to correct it, please help me out :(

Hello guys, I was using a class assignment using matlab, and the code is provided by the professor. All we need to do is use plug the function in and run it. But for some reason, I got this error:
? Error using ==> mpower
Inputs must be a scalar and a square matrix.

Error in ==> @(x)(e^(cos(x))+8*x^2-3-x-4)^(1/5)


Error in ==> fpi at 5
x(i+1)=g(x(i));

I don't see a problem in that, can someone point it out for me?
 
Physics news on Phys.org


Thank you for your reply, I found the answer. Seems like in matlab, there is no "e", have to use exp() instead.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K