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.

3 views (last 30 days)
% 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;

Answers (1)

James Tursa
James Tursa on 23 May 2023
Edited: James Tursa on 23 May 2023
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 ...

Tags

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!