Compute polynomial coefficient with unequal vector?
    2 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    AniCnx
 el 17 de Oct. de 2017
  
    
    
    
    
    Comentada: AniCnx
 el 17 de Oct. de 2017
            Hello all, I have question about to compute polynomial coefficient with unequal number of membership of 2 vectors. If I have vector A as 10x1 and vector B as 7x1, can I possibly compute coefficient with order 4 of this 2 vectors? Thanks Ani.
2 comentarios
  KSSV
      
      
 el 17 de Oct. de 2017
				A fourth order polynomial has five unknowns..you have seven points known..you should be able to do it eh.
Respuesta aceptada
  KSSV
      
      
 el 17 de Oct. de 2017
        %%a random data
x = rand(10,1) ;
y = rand(7,1) ;
% sort x in ascending order and pick first seven 
x = x(1:7) ;
%
[x,idx] = sort(x) ;
y = y(idx) ;
%%fit fourth order polymomial
[P,S] = polyfit(x,y,4) ;
x1 = linspace(min(x),max(x));
y1 = polyval(P,x1);
figure
plot(x,y,'-or')
hold on
plot(x1,y1)
hold off
3 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

