MATLAB Answers

0

Obtain a specif value in a vector

Asked by Giuseppe Pintori on 22 Oct 2019
Latest activity Commented on by Giuseppe Pintori on 22 Oct 2019
Hi guys, I'm having a problem; let's say I have a code like the following:
clear
g = ones(1,1);
serv = (randi([0, 10], [10,10])).*g;
meanserv = mean(serv);
At this point, what I need is a value of g such that meanserv(1,1) is equal to 0.3 and meanserv(1,10) is equal to 0.7; I was thinking to use an fsolve or a simple while/if but I can't figure out how to obtain those results.
Thanks in advance.

  4 Comments

Show 1 older comment
I was using something like this
while (meanserv(1,1) > 0.3) && (meanserv(1,10) < 0.7)
if meanserv(1,1) < 0.3
break
end
if meanserv(1,10) > 0.7
break
end
end
Adam
on 22 Oct 2019
Nothing changes in that while loop though!

Sign in to comment.

Products


Release

R2019b

0 Answers