I would like to plot a graph which shows the results of a for loop that derived a matrix Y(20,1001). I would like all the results of the iterations of Y to be plotted as one continuous line graph instead of all the iterations separately. However my code plots a graph with several lines of different colour, which I'm assuming its plotting the result of each iteration separately in the same graph. Hope I'm explaining my self clearly. My loop is underneath. Any tips would be appreciated. Thanks.
f=0:1000; w=2*pi*f; F=1;
%plate dimensions ad exciter location
%Plate data - Fibre board
h=3.25e-3 ; %thickness
E=1.4e9 ; %Young?s modulus
M=265*h; %Mass per unit area
mu=0.3; %Poisson?s ratio
eta=4e-2; %Damping Factor
D=(E*(h^3))/(12*(1-mu)); %flexural rigidity
% calculate the eigenfrequencies and modes
i = 0;
for m = 1:5;
for n = 1:5;
i = i + 1;
wmn(i)=(sqrt(D/(p*h)))*((((n*pi)/Lx)^2)+(((m*pi)/Lz)^2)); %modal angular frequency
mode(i,:) = [m n];
end end end
%sort the eigenfrequencies and the mode numbers
[wmn, I] = sort(wmn); wmn = wmn';
T = [wmn, modesort];
for q = 1:length(T(:,1))
i=i+1; Y(i,:)=((4./(Lx.*Lz)).*(1./p))... .*(((sin((T(q,2).*pi.*x0)./Lx).*sin((T(q,3).*pi.*z0)./Lz))... .*(sin((T(q,2).*pi.*x0)./Lx).*sin((T(q,3).*pi.*z0)./Lz)))... ./((-w.^2)+(((T(q,1)).^2)*(1+(1j*(2*eta/(T(q,1))))))));
No products are associated with this question.
Hi Walter, I changed as you suggested but get the same results. I added the whole code to my question above.
Hi Catarina, Y is a 20*1001 matrix! When you use plot, there'll be 20 lines for each row. If Y should be one line, you should not make it a 20*2001 matrix at first, or reshape it into a vector:
And you don't need to put PLOT into for loop if you don't want the plot of each iteration.
Play games and win prizes!Learn more