issue in spectralMatch or am I doing something wrong?

22 ビュー (過去 30 日間)
Molly Fort
Molly Fort 2025 年 10 月 28 日 14:14
回答済み: Parth Parikh 2025 年 11 月 5 日 5:49
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.

回答 (2 件)

Anmol
Anmol 2025 年 11 月 3 日 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,
  1. 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.
  2. 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.
I hope you find this useful.

Parth Parikh
Parth Parikh 2025 年 11 月 5 日 5:49
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.

カテゴリ

Help Center および File ExchangeHyperspectral Image Processing についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by