Summation for every value of "n" (or summation with looping)
    4 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
% Hi, i need to find the "Q" variable for every instance of "n" and divide those values by "Pr"  
clear all
clc;
n=[1:1:50]
B=7.5 % angle value
%Q= (1+2*(cos(n1*B))^(5/2)+2*(cos(n2*B)^(5/2) + ... ); --> this is an
%example of how iterations should be in short; "1+2*(cos(n*B))^(5/2)"
Pr= 395
%P1= Pr/Q
0 Commenti
Risposte (1)
  Alan Stevens
      
      
 il 14 Nov 2022
        Like so:
B=7.5; % angle value
fn = @(n) (1+2*cos(n*B)).^5/2;
n=1:50;
Qn = fn(n);
Q = sum(Qn);
Pr= 395;
P1= Pr/Q;
disp(P1)
% Or do you mean
Q(1) = fn(1);
for n = 2:50
    Q(n) = fn(n) + Q(n-1);
end
P1 = Pr./Q;
disp(P1)
4 Commenti
  Alan Stevens
      
      
 il 7 Dic 2022
				
      Modificato: Alan Stevens
      
      
 il 7 Dic 2022
  
			Looks like it should be
fn = @(n) 2*cos(n*B).^(5/2);
Vedere anche
Categorie
				Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

