curvefitting of complex number
1 view (last 30 days)
Show older comments
Supreeth D K
on 3 Nov 2022
Answered: Harshit Gupta
on 15 Nov 2022
I get following error when i use Lsqcurvefit
Warning: Imaginary parts of complex X and/or Y arguments ignored.
> In myfun (line 11).
I want both real and imaginary parts
1 Comment
Accepted Answer
Harshit Gupta
on 15 Nov 2022
Hi Supreeth,
As per my understanding, you are getting the following warning:
Warning: Imaginary parts of complex X and/or Y arguments ignored.
And you want both real and imaginary parts to be included in your plot, while using "lsqcurvefit".
Please refer below to resolve your query:
- "lsqcurvefit" can solve complex-valued problems directly. Note that bound constraints do not make sense for complex values. For a complex problem with bound constraints, split the variables into real and imaginary parts. See Fit a Model to Complex-Valued Data.
- If you want to plot the real part of a vector versus the complex part, pass the vector as a single complex vector to the "plot" function.
- If you want to plot the magnitude of the elements, use the “abs” function on the vector before passing it to the “plot” function.
- Please refer to the following link for more information on the “abs” function: https://www.mathworks.com/help/matlab/ref/abs.html
- Please refer to the following link for more information on the “plot” function: https://www.mathworks.com/help/matlab/ref/plot.html
- You can refer to the following MATLAB Answers link for more information about this warning: https://www.mathworks.com/matlabcentral/answers/96197-why-do-i-get-warning-messages-about-imaginary-parts-of-complex-x-and-or-y-arguments-ignored
0 Comments
More Answers (0)
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!