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.
3 件のコメント
Debanjan Borthakur
2019 年 6 月 10 日
Debanjan Borthakur
2019 年 6 月 10 日
Debanjan Borthakur
2019 年 6 月 10 日
カテゴリ
ヘルプ センター および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!