Effacer les filtres
Effacer les filtres

Translate sine coding? Need understanding

2 vues (au cours des 30 derniers jours)
Nicholas
Nicholas le 19 Sep 2022
Modifié(e) : Torsten le 19 Sep 2022
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

Réponses (1)

Steven Lord
Steven Lord le 19 Sep 2022
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."

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by