Plotting graph for iterations of a for loop
이전 댓글 표시
Essentially I have the roots of a polynomial, which have been converted into a 3x7 matrix. I want my code to run through each column of the matrix and plot a graph for each iteration. I can get it to run through the loop and plot multiple graphs, but it's always for the first column of the graph, and not moving on to the next one. Is anyone able to advise how I might be able to move my for-loop onto the next column? Thanks!
alpha_0 = [-1,-0.5,-0.1,0,0.1,0.5,1];
N = numel(alpha_0);
R = nan(3,N);
for alpha = 1:N % loop over indices
p = [1, 2*alpha_0(alpha), alpha_0(alpha)^2, -1/2];
R(:,alpha) = roots(p);
end
Roots = array2table(R)
[numRows, numCols] = size(R);
for col = R([1:7]) %for each column
for rows = 1:size(numRows) %for each row
i = R(:,rows)
delta_w = (i * (n_bn_0)^(1/3)) .* (k .* V_s)./((1 + (klambda_D).^2).^(1/2));
omega3 = ((k .* V_s)./((1 + (klambda_D).^2).^(1/2)) + delta_w)/w_pe;
h = figure;
plot(klambda_D, omega3, 'DisplayName', 'omega_3');
ylim([0 0.1])
xlabel('k * \lambda_D')
ylabel(' omega \omega')
grid on
hold on
end
saveas(h,sprintf('omega3%d.png',rows));
hold off
lgd = legend;
lgd.FontSize = 14;
lgd.Title.String = 'Disp relations';
col = col + 1;
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!