How to fix the error using -FROMSTRUCT ?

9 ビュー (過去 30 日間)
Gauri
Gauri 2024 年 11 月 23 日
コメント済み: Walter Roberson 2024 年 11 月 23 日
i am using the following matlab code
% Save the transformation directly without using a structure
[outputDir, baseName, ~] = fileparts(outputFiles{i});
transformFile = fullfile(outputDir, [baseName, '_tform.mat']);
save(transformFile, 'tform', '-fromstruct');
It is giving the error as
The -FROMSTRUCT option must be followed by a scalar structure variable.
I request you to kindly suggest me how to fix it.

回答 (1 件)

埃博拉酱
埃博拉酱 2024 年 11 月 23 日
The error message is clear: -fromStruct asks you to enter a struct scalar, and then save each field name of the input struct as the name of each variable of the .mat. The 'tform' you type is an array of characters, not a struct.
  1 件のコメント
Walter Roberson
Walter Roberson 2024 年 11 月 23 日
In other words you need
save(transformFile, '-fromstruct', tform)
provided that tform is a structure.
Notice that in this case, tform is the structure itself, not the name of the structure.
In the case where tform is the name of a structure (rather than an expression that yields a structure), then equivalent would be
save(transformFile, '-struct', 'tform')

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB Compiler SDK についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by