필터 지우기
필터 지우기

how to multiply each row in a column by different numbers

조회 수: 4 (최근 30일)
Passband  Modulation
Passband Modulation 2012년 10월 5일
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
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.
Passband  Modulation
Passband Modulation 2012년 10월 5일
it says:
Error in ==> Untitled3 at 5 s = a(k,1)-56.97*cosd(3.6*k)-31.98*sind(3.6*k);
how to fix it, i really have no any idea.

댓글을 달려면 로그인하십시오.

채택된 답변

John
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.
  댓글 수: 1
Passband  Modulation
Passband Modulation 2012년 10월 6일
a and k are of the same size.
and thank you for your kind reply!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by