Matlab相关函数

发布于 2024-10-16 03:53:49 字数 319 浏览 7 评论 0 原文

function letter=read_char(imgn, num_letters)

global templates

comp=[ ];

for n=1:num_letters

    sem=corr2(imgn, templates{1,n});

    comp=[comp sem];

end

vd=find(comp==max(comp));

有人可以解释一下“FOR”循环的作用以及“vd”是如何计算的吗? 另外,变量“comp”是什么以及它看起来是什么样子,因为数组还包含其自身和另一个从 corr2 函数计算得出的变量“sem”。 谢谢

function letter=read_char(imgn, num_letters)

global templates

comp=[ ];

for n=1:num_letters

    sem=corr2(imgn, templates{1,n});

    comp=[comp sem];

end

vd=find(comp==max(comp));

Can someon please explain what the 'FOR' loop does and how 'vd' is calculated?
Also, what is the variable 'comp' and what will it looks like as the array also contains itself and another variable 'sem' which is calculated from the corr2 function.
thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一腔孤↑勇 2024-10-23 03:53:49

for 循环 创建循环变量 n第一个循环从 1 开始,每个后续循环加 1,直到达到 num_letters。这意味着循环将执行 num_letters 次。

变量comp首先被初始化为空矩阵 <代码>[]。在循环内,计算矩阵 imgn 和另一个矩阵 templates{1,n}(从 元胞数组) 使用函数 CORR2。使用 sem 附加到数组 comp rel="nofollow">水平串联。这最终将导致 comp 成为 1×num_letters 相关系数数组。

变量vd 存储数组索引,其中comp 中的值等于comp 中找到的最大值。这是使用函数 MAXFIND比较运算符 ==

将来,我强烈建议您首先使用在线文档来尝试帮助您更好地了解 MATLAB 的工作原理。这是非常很好的文档。我从中学到了大部分知识。 ;)

The for loop creates a loop variable n that starts at 1 for the first loop and is incremented by 1 for each successive loop until it reaches num_letters. This means the loop will execute num_letters times.

The variable comp is first initialized to the empty matrix []. Within the loop, a 2-D correlation coefficient is computed between the matrix imgn and another matrix templates{1,n} (indexed from a cell array) using the function CORR2. The correlation coefficient sem is appended to the array comp using horizontal concatenation. This will ultimately result in comp being a 1-by-num_letters array of correlation coefficients.

The variable vd stores the array indices where values in comp are equal to the maximum value found in comp. This is done using the functions MAX and FIND and the comparison operator ==.

In the future, I would urge you to first use the online documentation to try and help you better understand how MATLAB works. It is very good documentation. I've learned most of what I know from it. ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文