<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt"><div class="" style=""><span class="" style="">Oi Rodrigo  entendi um pouco o que voce disse, mas nao consegui juntar com a construção da minha matriz, ja que é ela  o parâmetro da função.</span></div><div class="" style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;"><span class="" style=""><br></span></div><div class="" style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;"><span class="" style=""> Estou fazendo
  umas funções no meu mestrado na area de controle em que preciso passar matrizes com incertezas politópicas,  como parametros,, no caso as incertezas é a variável p, entro tambem com a variação dessas incertezas np exemplo abaixo chamei de limite,,,</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style=""><br class="" style=""></span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style="">vou detalhar um pouco mais uma função bem modesta  para voce me ajudar e dizer onde  posso aproveitar sua
 sugestão.</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style=""><br class="" style=""></span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style=""><br class="" style=""></span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style="">-----    programa principal
  -----------------------------------------</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style=""><br class="" style=""></span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style="">limite = 3                              #  da o limite de p , no caso p vai variar de 1  a  4  (verifique que eu não defini a variável p)          </span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family:
 HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span style="background-color: transparent;" class="">A =  rbind ( c( p + 8 ,     3),     </span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span style="background-color: transparent;" class="">                  c( 5      , p - 1)  </span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span
 style="background-color: transparent;" class=""><br class="" style=""></span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class="">calcula_matriz(A, limite)         #  chamada da função</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style=""><br class="" style=""></span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style="">------
   agora a funcão --------</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style=""><br class="" style=""></span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style="">calcula_matriz <-   function (A, limite) {</span><span style="background-color: transparent;" class=""> </span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span
 class="" style="">   for ( p in 1 : limite ) {                 #  só aqui definir p</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style="">       print (A)</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style="">   }</span><span style="background-color: transparent;" class="">  </span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial,
 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style="">}</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style=""><br class="" style=""></span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style="">------------------------------------------------------------------</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent;
 font-style: normal;" class=""><span class="" style="">O resultado seria:</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style=""><br class="" style=""></span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style="">para p = 1           A = [9   3;  5  0]</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span
 class="" style=""><span style="font-size: 10pt;" class="">para p = 2           A = [10  3;  5  1]</span> </span></div><div style="color: rgb(0, 0, 0); font-size: 10pt; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style=""><span class="" style="font-size: 10pt;">para p = 3           A = [11  3;  5  2]</span><span style="font-size: 10pt;" class=""> </span><span style="font-size: 10pt;" class=""> </span></span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style=""><br class="" style=""></span></div><div
 style="color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;" class=""><span class="" style="">agradeço  a  quem puder ajudar,</span></div><div class="" style=""></div><div class="" style=""> </div><div class="" style=""><span style="color:rgb(0, 0, 255);font-style:italic;font-weight:bold;font-family:times new roman, new york, times, serif;" class="">Waldelene Moura</span><br style="color:rgb(0, 0, 255);font-style:italic;font-family:times new roman, new york, times, serif;" class=""><span style="color:rgb(0, 0, 255);font-style:italic;font-family:times new roman, new york, times, serif;" class="">Analista de Sistemas</span><br style="color:rgb(0, 0, 255);font-style:italic;font-family:times new roman, new york, times, serif;" class=""><span style="color:rgb(0, 0,
 255);font-style:italic;font-family:times new roman, new york, times, serif;" class="">Universidade Federal do Maranhão - PROEN</span><br style="color:rgb(0, 0, 255);font-style:italic;font-family:times new roman, new york, times, serif;" class=""></div><div style="font-family:'times new roman', 'new york', times, serif;font-style:italic;" class=""><span style="color:rgb(0, 0, 255);" class=""> </span></div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 10pt;" class=""> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;" class=""> <div dir="ltr" class="" style=""> <font size="2" face="Arial" class="" style=""> Em Quinta-feira, 5 de Junho de 2014 11:39, Rodrigo Coster <rcoster@gmail.com>
 escreveu:<br class="" style=""> </font> </div>  <br class="" style=""><br class="" style=""> <div class="" style=""><div id="yiv8521402219" class="" style=""><div class="" style=""><div dir="ltr" class="" style="">Waldelene,<div class="" style=""><br clear="none" class="" style=""></div><div class="" style="">O que da pra fazer é definir o valor do parâmetro como padrão. Por exemplo:</div><div class="" style=""><br clear="none" class="" style=""></div><div class="" style=""><div class="" style="">calcular_matrizes <- function(x = p + 2) {</div><div class="" style=""><span class="" style="white-space:pre;">   </span>p <- rnorm(1)</div>
<div class="" style=""><span class="" style="white-space:pre;">     </span>return(x)</div><div class="" style="">}</div></div><div class="" style="">calcular_matrizes()<br clear="none" class="" style=""></div><div class="" style=""><br clear="none" class="" style=""></div><div class="" style="">Ele só vai executar o 'x = p + 2' quando a variável x for chamada, que ocorre somente depois de definir o valor de p.</div>
<div class="" style=""><br clear="none" class="" style=""></div></div><div class="" style=""><br clear="none" class="" style=""><br clear="none" class="" style=""><div class="" style="">2014-06-05 11:27 GMT-03:00 Waldelene Moura <span dir="ltr" class="" style=""><<a rel="nofollow" shape="rect" ymailto="mailto:waldelene@yahoo.com.br" target="_blank" href="mailto:waldelene@yahoo.com.br" class="" style="">waldelene@yahoo.com.br</a>></span>:<br clear="none" class="" style="">
<blockquote class="" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="" id="yiv8521402219yqt40674" style=""><div class="" style=""><div style="color:#000;background-color:#fff;font-family:HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt;" class="">
<div class="" style=""><span class="" style=""></span></div><div style="display:table;width:auto;word-wrap:break-word;padding-top:12px;padding-left:0px;font-family:'Helvetica Neue', 'Segoe UI', Helvetica, Arial, 'Lucida Grande', sans-serif;" class="">
<div class="" style=""><div class="" style=""><div style="font-family:HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:10pt;" class=""><div class="" style=""><br clear="none" class="" style=""></div><div style="background-color:transparent;" class="">
<span class="" style="">Olá pessoal, se alguem puder me ajudar nesse problema agradeço.</span></div><div style="background-color:transparent;" class=""><span class="" style=""><br clear="none" class="" style=""></span></div><div style="background-color:transparent;" class="">É o seguinte</div><div style="background-color:transparent;" class="">
<br clear="none" class="" style=""></div><div style="background-color:transparent;" class="">Preciso passar como parâmetro de uma função <span style="font-weight:bold;" class="">uma matriz</span> que possui nos seus </div><div style="background-color:transparent;" class="">
elementos uma variável <span style="font-weight:bold;" class="">p</span>,  sendo que essa variável p só vai assumir valores dentro da função</div><div style="background-color:transparent;" class="">chamada, <span style="font-size:10pt;" class="">exemplo,</span></div>
<div style="background-color:transparent;" class=""><br clear="none" class="" style=""></div><div style="background-color:transparent;" class=""><br clear="none" class="" style=""></div><div style="background-color:transparent;" class="">A = cbind(c(p+5, 6),</div><div style="background-color:transparent;" class="">
               c(10, p+8))</div><div style="background-color:transparent;" class=""><br clear="none" class="" style=""></div><div style="background-color:transparent;" class="">calcular_matrizes (A)</div><div style="background-color:transparent;" class=""><br clear="none" class="" style="">
</div><div style="background-color:transparent;" class=""><br clear="none" class="" style=""></div><div style="background-color:transparent;" class="">dentro da função <span style="font-weight:bold;" class="">calcular_matrizes</span> tenho que achar valores para essa matriz para varios valores de <span style="font-weight:bold;" class="">p</span></div>
<div style="background-color:transparent;" class=""><br clear="none" class="" style=""></div><div style="background-color:transparent;" class="">A pergunta é, como passar esse parâmetro, <span style="font-weight:bold;" class="">no caso a matriz A</span> na função, sem dar erro de que a variável <span style="font-weight:bold;" class="">p</span> não foi definida? (object 'p' not found).</div>
</div></div></div></div><span class="" style=""><font color="#888888" class="" style=""></font></span><div class="" style=""></div><div class="" style=""> </div><div class="" style=""><span style="color:rgb(0,0,255);font-style:italic;font-weight:bold;font-family:times new roman, new york, times, serif;" class="">Waldelene Moura</span><br clear="none" style="color:rgb(0,0,255);font-style:italic;font-family:times new roman, new york, times, serif;" class="">
<span style="color:rgb(0,0,255);font-style:italic;font-family:times new roman, new york, times, serif;" class="">Analista de Sistemas</span><br clear="none" style="color:rgb(0,0,255);font-style:italic;font-family:times new roman, new york, times, serif;" class="">
<span style="color:rgb(0,0,255);font-style:italic;font-family:times new roman, new york, times, serif;" class="">Universidade Federal do Maranhão - PROEN</span><br clear="none" style="color:rgb(0,0,255);font-style:italic;font-family:times new roman, new york, times, serif;" class="">
</div><div style="font-family:'times new roman', 'new york', times, serif;font-style:italic;" class=""><span style="color:rgb(0,0,255);" class=""> </span></div></div></div></div><br clear="none" class="" style="">_______________________________________________<br clear="none" class="" style="">

R-br mailing list<br clear="none" class="" style="">
<a rel="nofollow" shape="rect" ymailto="mailto:R-br@listas.c3sl.ufpr.br" target="_blank" href="mailto:R-br@listas.c3sl.ufpr.br" class="" style="">R-br@listas.c3sl.ufpr.br</a><br clear="none" class="" style="">
<a rel="nofollow" shape="rect" target="_blank" href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" class="" style="">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a><br clear="none" class="" style="">
Leia o guia de postagem (<a rel="nofollow" shape="rect" target="_blank" href="http://www.leg.ufpr.br/r-br-guia" class="" style="">http://www.leg.ufpr.br/r-br-guia</a>) e forneça código mínimo reproduzível.<br clear="none" class="" style=""></blockquote></div><br clear="none" class="" style=""></div></div></div><br class="" style=""><br class="" style=""></div>  </div> </div>  </div> </div></body></html>