Filter löschen
Filter löschen

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 Ansicht (letzte 30 Tage)
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.

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by