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