my code output is right but my graph gives me nothing it's blank and I don't know why it wont work there are no error just gives a graph with nothing on it
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
the fprintf's are correct its just the plot that won't work and the goal is to plot time on the x and stocks owned on the y which are the vectors called time and stock
0 Kommentare
Akzeptierte Antwort
VBBV
am 30 Nov. 2022
Bearbeitet: VBBV
am 30 Nov. 2022
Use loop index
if Price(i) < buy
stock(i) = stock(i)+25; % use loop index
...
elseif sell < Price(i)
stock(i) = stock(i) - 50; % use loop index
else
stock(i) = stock(i)+0;
end
1 Kommentar
VBBV
am 30 Nov. 2022
% before start of the loop
stock = zeros(1,length(price)); % allocate a vector
stock(1) = 200; % starting stock
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!