简体   繁体   English

Matlab结构数组被视为向量

[英]Matlab structure arrays treated as vectors

I'd like my program to not treat this: 我希望我的程序不要这样处理:

{0:1000}
{ones(1,1000)}

not as vectors when I input them for my structure array. 当我为结构数组输入向量时,它们不是向量。 Any idea on how to do this? 关于如何执行此操作的任何想法? Thanks in advance. 提前致谢。

if you want a complete other action of the function depending on the input type, you'll have to write a wrapper, catching off this input type. 如果您希望根据输入类型完成该功能的其他操作,则必须编写包装器,以脱离此输入类型。 This is possible with the isa function. 使用isa函数可以做到这一点。 It works as follows 它的工作方式如下

if isa(var,'double')
    % do something with the double
elseif isa(var,'struct')
    % do something with the structure
else
    % ...
end

OR maybe it's possible to avoid this wrapping and treat all variables alike, but then you'll have to provide a bit more information about this function and what you want it to do... 或者,也许可以避免这种包装,并且对所有变量都一视同仁,但是随后您将不得不提供有关此功能及其所需功能的更多信息...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM