Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Error: Unable to perform assignment because the left and right sides have a different number of elements.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
clear all;
close all;
clc;
%% Define Parameters
Yo = 250; %Yield stress (N/mm^2)
Do = 15; %Diameter of the die inlet (mm)
D1 = 9; %Diameter of the die outlet (mm)
Eps = 300; %Strain hardening exponent
u = 0; % Friction coefficient
%% Initialize Variables
x(1)=0;
SigmaX(1)=0;
D=Do;
Y=Yo;
p(1)=Yo; %Die pressure
alpha = 12*(pi/180); %radians
%% Define number of slices
n = 100;
%% Calculate step size
dD = (Do-D1)/n;
dx = dD/(2*tan(alpha));
%% Begin loop
for i = 2:n+1
dSigmaX=(2/D)*(SigmaX+((Y-SigmaX)*(1+u*cot(alpha))))*dD;
SigmaX(i)=SigmaX(i-1)+dSigmaX;
D = D-dD;
Epsilon = 2*log(Do/D);
Y = Yo+(Eps*Epsilon);
p(i) = Y-SigmaX(i);
x(i) = x(i-1)+dx;
end
%% Plots
plot(x, SigmaX, 'o', x, p, '*')
xlabel('x')
ylabel('Pressure')
title('Case A')
grid on
**SigmaX(i)=SigmaX(i-1)+dSigmaX; ** this line is giving me the error 'Unable to perform assignment because the left and right sides have a different number of elements.'
1 comentario
Jacob Wood
el 18 de Feb. de 2020
It looks like dSigmaX is a vector, instead of a single element, if SigmaX is a vector. Perhaps you want something like:
dSigmaX=(2/D)*(SigmaX(i-1)+((Y-SigmaX(i-1))*(1+u*cot(alpha))))*dD;
Respuestas (1)
Srivardhan Gadila
el 21 de Feb. de 2020
From line 24, the size of dSgimaX is same as the size of SigmaX which is increasing after every iteration.
In line 25 "SigmaX(i-1)+dSigmaX" is a vector and we are assigning it to a scalar (i.e., an element of the array SigmaX), which is the cause of the error.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!