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 次查看(过去 30 天)
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.

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by