How can I take an integer like n=1:1:50 and get the output for each value?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to plot my output for each input and the input is from 1 to 50, but I am not sure why my code is not working.
n=1:50; %my range, I want to check for each n values
f=n*175*10^6; % want to get frequency for each n
c=(sin(n*pi*d))/(n*pi*d) %d,tr,T these are my fixed values
d1=(sin((n*pi*tr)/T))/((n*pi*tr)/T);
In=2*d*Ipp*c*d1;
E=(In*f*L)/(0.8*r); %I am not getting E for each n values
0 Kommentare
Antworten (2)
Walter Roberson
am 30 Okt. 2021
d = rand() %since it was not defined
T = rand() %since it was not defined
tr = rand() %since it was not defined
L = rand() %since it was not defined
r = rand() %since it was not defined
Ipp = randi(255); %since it was not defined
n=1:50; %my range, I want to check for each n values
f=n*175*10^6; % want to get frequency for each n
c=(sin(n*pi*d))./(n*pi*d) %d,tr,T these are my fixed values
d1=(sin((n*pi*tr)/T))./((n*pi*tr)/T);
In=2*d*Ipp*c.*d1;
E=(In.*f*L)/(0.8*r);
plot(n, E)
0 Kommentare
Sulaymon Eshkabilov
am 30 Okt. 2021
Without knowing the size of your variables and just presuming some variables to be scalar and others to be a vector, here is the corrected code that is based on the color operator (:) :
n=1:50; %my range, I want to check for each n values
f=n*175*10^6; % want to get frequency for each n
c=(sin(n(:).*pi*d))./(n(:).*pi*d) %d,tr,T these are my fixed values
d1=(sin((n(:).*pi*tr)./T))./((n(:)*pi*tr)./T);
In=2*d(:).*Ipp*c*d1;
E=(In*f(:).*L)./(0.8*r); %I am not getting E for each n values
Presumably, you have here d and L or r to be a vector with a certain length.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
