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 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
VBBV
on 30 Nov 2022
Edited: VBBV
on 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 Comment
VBBV
on 30 Nov 2022
% before start of the loop
stock = zeros(1,length(price)); % allocate a vector
stock(1) = 200; % starting stock
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!