Error "Error using Delaunay Data points in complex number format are not supported. Use REAL and IMAG to extract the real and imaginary components."
조회 수: 75 (최근 30일)
이전 댓글 표시
Hi Matlab Team,
I have generated 500 parameters, by lhsdesign, which is a matrix 500 * 15 size, I call it "LHSparametertable".
Now, I put them as an input to my code (to run 500 times), to receive the output. I need some parameters to be integer, so I use floor function, to receive the integer part of them. Something like this:
[my_output] = my_function( floor(LHSparametertable(i,j)), LHSparametertable(i,j+1)...);
In my function, I use delaunay, but when I run the code, (in one of this 500 times) I received this error, while I do not have any complex number, is the problem with floor? If so, how can I just use the integer part of the number without using floor?
Error using delaunay
Data points in complex number format are not supported.
Use REAL and IMAG to extract the real and imaginary components.
Thanks
댓글 수: 5
Walter Roberson
2024년 10월 25일 19:34
You created a number of inputs using lhsdesign .
There are several possibilities here:
- lhsdesign might have somehow generated complex values. I do not see how this could be possible. If it is happening it would be interesting to test with 'Smooth', 'off'
- You are extracting two or three columns from LHSparametertable and passing those directly to delaunay but delaunay is complaining about complex values even though the inputs are definitely completely real. If so.. strange!
- Most likely: you are using the values from LHSparametertable to compute something, and you are passing that something to delaunay but delaunay is complaining about complex values. In this case, you need to check the process of computing whatever it is you pass to delaunay.
You could use the debugger to stop at the delauny call, and save the inputs to a .mat file and attach the .mat file here for testing.
채택된 답변
Shishir Reddy
2024년 11월 5일 10:28
편집: Shishir Reddy
2024년 11월 5일 10:28
Hi Neda
The error you're encountering with the delaunay function suggests that at some point, complex numbers are being passed as input. The floor function itself should not introduce complex numbers, but there might be other parts of your code or data that are causing this issue.
Kindly refer the following steps to understand the cause of the error –
1. Ensure that the ‘LHSparametertable’ does not contain any complex numbers. This can be verified by checking the data type of your matrix.
if ~isreal(LHSparametertable)
error('LHSparametertable contains complex numbers.');
end
2. Debugging statements can be added to identify when the complex number error occurs. The values at which the error occurs can be printed as follows:
try
my_output = my_function(floor(LHSparametertable(i,j)), LHSparametertable(i,j+1));
catch ME
fprintf('Error at iteration %d with inputs: %f, %f, ...\n', i, LHSparametertable(i,j), LHSparametertable(i,j+1))
rethrow(ME);
end
If you suspect that complex numbers are being introduced by accident, to resolve the issue, ensure that only the real parts are used.
real_value = real(LHSparametertable(i, j));
By following these steps, you should be able to identify and resolve the source of the complex number issue in the code.
For more information regarding the real function used to extract the real part of the complex number, kindly refer the following documentation.
I hope this helps.
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!