I've been stuck for way too long on this problem, I really just need someone to help me with the syntax I need for this problem.

1 view (last 30 days)
perform the following tasks (you are not allowed to use the find function or other matlab functions like it in matlab):
•Prompt the user to input a random vector of integers. You should use the matlab function input with a message to tell what type of input the users should enter.
•Use a for loop to iterate through the vector of integers and find the location/locations(the value of the for loop index) in the vector where the number 5 appears in the vector.
•Output the locations in the vector where the number 5 appears and the number oftimes the number 5 appears in the vector using fprintf.
My teacher hasn't spent any time teaching us syntax at all, she only ever goes over flow charts in class, then tells us to use google to complete our assignments like this. She hasn't recommended any kind of text to use or anything either. I generally spend 12+ hours on assignments, but I've legitimately been trying to figure this one out for days and I'm absolutely stuck. Any help that anyone is willing to offer would be incredible. I've tried many different routes, and I just keep deleting them because they're full of errors. I'll at least post the little bit I have so far.

Accepted Answer

VBBV
VBBV on 4 Apr 2021
%if true
for b = 1: x
if a(b) == 5
% do some thing here
end
end

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!