how to multiply each row in a column by different numbers
3 ビュー (過去 30 日間)
古いコメントを表示
say, a file consists of a single column with 10000 rows
load file.txt
a = file;
k=1:10000;
s = a(k,1).*cosd(3.6*k);
k=0:10000;
plot(k,s)
xlabel('k');
it does work at all, could anyone help?
2 件のコメント
Image Analyst
2012 年 10 月 5 日
Do you know how to use the debugger to step though your code? This would be easily solved if you did that.
採用された回答
John
2012 年 10 月 5 日
Try this if a is a column vector:
load file.txt
a = file;
k = [1:size(a,1)]';
s = a.*(cosd(3.6*k));
plot(k,s)
xlabel('k');
Alternatively, k can be any column vector you wish to perform element-by-element multiplication with a. Just make sure a and k are of the same size.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!