using for loop in alignsignal function
显示 更早的评论
I am using the function [Xa,Ya] = alignsignals(X,Y). Now I want to perform this operation on an arry of X and Y's and store them on Xa's and Ya's. Any suggestions. Here X and Y will be a matrix instead of a single vector.
回答(2 个)
KALYAN ACHARJYA
2019-6-10
编辑:KALYAN ACHARJYA
2019-6-10
%I assumed both (X & Y) have same lengths
for i=1:lengths(x)
[Xa(i),Ya(i)]=alignsignals(X(i),Y(i));
end
For example
y1=[1 2 3 4];
y2=[4 5 6 7];
x=[];
y=[];
for i=1:length(y1)
[x(i) y(i)]=fun4(y1(i),y2(i));
end
fun4
function [x y]=fun4(a,b)
x=a+b;
y=a-b;
end
If I misundestood your question, let me know.
5 个评论
Debanjan Borthakur
2019-6-10
编辑:Debanjan Borthakur
2019-6-10
Debanjan Borthakur
2019-6-10
Debanjan Borthakur
2019-6-10
KALYAN ACHARJYA
2019-6-10
编辑:KALYAN ACHARJYA
2019-6-10
@Debanjan data?
Debanjan Borthakur
2019-6-10
KSSV
2019-6-10
[m,n] = size(X) ;
Xa = zeros([],m) ;
Ya = zeros([],n) ;
for i = 1:n
[xa,ya] = alignsignals(X(:,i),Y(:,i)) ;
Xa(:,i) = xa ;
Ya(:,i) = ya ;
end
If function is shown...may be it can be vectorised and work for entire matrix.
类别
在 帮助中心 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!