- You can try running this example https://www.mathworks.com/help/releases/R2024b/images/ref/spectralmatch.html based on the version of MATLAB you are using.
- You can also try using “hcube.DataCube” instead of datacube = gather(hcube) in the code, as it might be possible the conversion is happening incorrectly.
issue in spectralMatch or am I doing something wrong?
22 views (last 30 days)
Show older comments
on the page for use of spectralMatch function this code is suggested:
score = spectralMatch(libData,hcube);
bw = score < threshold;
datacube = gether(hcube);
T = reshape(datacube,[size(datacube,1)*size(datacube,2) size(datacube,3)]);
Ts = zeros(size(T));
Ts(bw == 1,:) = T( bw==1 ,:);
Ts = reshape(Ts,[size(datacube,1) size(datacube,2) size(datacube,3)]);
but when run, error code pops up;
Unable to perform assignment because value of type 'hypercube' is not convertible to 'double'.
Caused by:
Error using double
Conversion to double from hypercube is not possible.
0 Comments
Answers (2)
Anmol
on 3 Nov 2025 at 7:47
Hi Molly,
I understand that you are trying to run the example provided in https://www.mathworks.com/help/releases/R2025b/images/ref/spectralmatch.html for “spectralMatch” function on MATLAB R2024b and while running the code script you are getting this error.
For possible workarounds,
Documentation link: https://www.mathworks.com/help/releases/R2024b/images/ref/spectralmatch.html
I hope you find this useful.
0 Comments
Parth Parikh
6 minutes ago
Hi Molly,
Thank you for bringing this issue. I’ve tested the spectralMatch example, and it appears to be running correctly on my end. To assist you further, could you please provide more details about how your hcube object was created? Additionally, which version of MATLAB are you currently using? Assuming that gether(hcube) is a typo. These information will help me give you a more precise answer.
Just to note that if you are using gather(hcube) in MATLAB versions R2024b or earlier, you might encounter issues because data retrieval was handled via hcube.DataCube in those versions.
0 Comments
See Also
Categories
Find more on Hyperspectral Image Processing 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!