How can ı solve this error ??Unable to perform assignment because the size of the left side is 1-by-5 and the size of the right side is 26-by-1.

1 次查看(过去 30 天)
% Constants
N = 100; % Number of parameter values
q1_range = linspace(0, 100, N);
q2 = 100;
q3 = 0;
q4 = 0;
% Initialize arrays to store pole data
poles_real = zeros(N, 5);
poles_imag = zeros(N, 5);
% Compute poles for each parameter value
for i = 1:N
q1 = q1_range(i);
polynomial = [1, q1, (289/11), (173*q1/14), q4, (2628/11), (2091*q1/19), q3, (63*q4/25), (10026/11), (6193*q1/8), q2, 5938, 3, 37945, 9, 93795, 1464591, 542, 793, 1994, 7, 6, 10, 15, 8143, 3];
roots_poly = roots(polynomial);
poles_real(i, :) = real(roots_poly);
poles_imag(i, :) = imag(roots_poly);
end
% Plot pole-spread
figure;
plot(poles_real, poles_imag, 'x');
xlabel('Real Part');
ylabel('Imaginary Part');
title('Pole-Spread of the Polynomial');
legend('Pole 1', 'Pole 2', 'Pole 3', 'Pole 4', 'Pole 5');
grid on;

回答(1 个)

James Tursa
James Tursa 2023-5-23
编辑:James Tursa 2023-5-23
You could expand the size of the LHS array. E.g.,
poles_real(i, 1:numel(roots_poly)) = real(roots_poly);
poles_imag(i, 1:numel(roots_poly)) = imag(roots_poly);
Whether these 26 roots is really what you wanted is another question ...

类别

Help CenterFile Exchange 中查找有关 Pole and Zero Locations 的更多信息

标签

产品


版本

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by