首先,我的编程技能不是很好,所以请耐心等待。Matlab:索引和相关值
我试图脚本在Matlab以下,R2015a:
1)给定一个特定向量(mag
),从该载体(Am
和A
)的第一个300个值来计算两个显着的值;
2)获取Am
值的索引,A
这两个索引(向量是对称的,所以A
会有两个索引)。
3)从另一载体(freq
)获取的值与之前的三个索引(索引从Am
相关联(fm
,f1
和f2
),第一A
和第二A
分别)。
4)最后,根据3)中的值计算D
。
到目前为止,这是我有:
Am=max(mag(1:300)); %Am is the maximum value of vector mag
A=Am/2^0.5; %A is the other desired value
[~,Im] = mag(1:300,Am); %Trying to get the Am index. Error: "Indexing cannot yield multiple results." I found that this error is usual when using variables with the same name, which is not the case.
fm=freq(Im); %Value of freq associated with Am
[~,I1] = mag(1:300,A,'first'); %Index of the first value of A
f1=freq(I1) ; %Value of freq associated with the first value of A
[~,I2] = mag(1:300,A,'second'); %Index of the second value of A
f2=freq(I1); %Value of freq associated with the second value of A
D=(f2^2-f1^2)/(4*fm)
我无法从mag
。任何提示和建议的欲望值获取相关freq
值更受欢迎。
并提前致谢!
发现我可以代替[〜,IM] = MAG(1:300,AM)通过 [〜,I1] = MAX(MAG(1:300)) 哪些工作正常。另外两个指标仍然存在问题。 –
在你使用'mag'作为变量的第一段代码中,作为一个函数。这里没有什么真正的意义。 – thewaywewalk
@ thewaywewalk,如果您正在尝试从* A *的两个值中获取索引,请忽略其中的内容。我似乎无法找到办法做到这一点,这是一个坏的尝试,我的坏。 –