Translate sine coding? Need understanding
조회 수: 1 (최근 30일)
이전 댓글 표시
Good afternoon, Im trying to gain a better understanding of this code. Could anyone help translate it for me?
width = 1920;
height = 1080;
T = linspace(0,1,width);
brightness = 126;
f = 10;
HorLine = uint8((sin(2*pi*f*T)+1)*0.5*brightness);
img = repmat(HorLine,height,1);
imshow(img)
Im new to MATLAB so please dont leave any detail out lol
댓글 수: 0
답변 (1개)
Steven Lord
2022년 9월 19일
To start off, I suggest you start with the free MATLAB Onramp tutorial to quickly learn the essentials of MATLAB.
Then work your way through the code, line by line, annotating it with notes (written as comments) about the purpose of each function call. You'll need to work from the innermost set of parentheses outward.
% T represents ...
T = linspace(0,1,width);
If you encounter a function whose purpose you're unsure about, call doc on the function name.
If after reviewing the documentation you're still unsure of what a particular line is doing, you should have enough information about what the code before it is doing to be able to ask a more focused question about that line. "The inputs to this call are T, which represents <explain what T is>, and Q, which represents <explain Q>. But I'm not sure why this line is calling <some function> on T and Q."
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!