Cannot express limits in arrays

1 visualización (últimos 30 días)
James Rodriguez
James Rodriguez el 5 de Mzo. de 2020
Comentada: Sindar el 5 de Mzo. de 2020
I cannot think of the correct title for this problem I am having so I apolgise for that initially.
I have a rectangle with fixed area , 4345. The height(Y) and width(Z) however change. Y is equal to or greater then Z. Z has a minimum value 33 and Y has a maximum value 212. I belive the minimum of Y and maximum of Z must be sqrt(4345) . I am trying to create a code that will let me multiply Z and Y together, while understanding their product will always be A.
A = 4345;
Z = [33:0.000001:sqrt(A)];
Y = [sqrt(A):0.000001:212];
A = Z*Y;
IYY = 1/12*Z*Y^3
However the problem is the arrays are not consistent. I thought about not using the arrays, in hope MatLab would understand that ZY would always equal A, however it then wont recognise Z or Y. without the array I dont know how to implement my limits of each. My end goal is to be able to plot how IYY changes for diffrent values of Y.

Respuesta aceptada

Sindar
Sindar el 5 de Mzo. de 2020
If the area is fixed, you don't want independent Y and Z:
A = 4345;
Z = [33:0.000001:sqrt(A)];
Y = A./Z;
Note that the condition Y<212 is guaranteed by Z>33 (4345/33 ~ 131)
  1 comentario
Sindar
Sindar el 5 de Mzo. de 2020
If you have a condition that is not already satisfied (here, Y<=100), you can enforce it manually:
A = 4345;
Z = [33:0.000001:sqrt(A)];
Y = A./Z;
Z(Y>100) = [];
Y(Y>100) = [];

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 5 de Mzo. de 2020
Editada: Walter Roberson el 5 de Mzo. de 2020
A = 4345;
Z = 33:0.000001:sqrt(A);
Y = A ./ Z;
Reconstructed_A = Z .* Y;
IYY = 1/2 * Z .* Y.^3;
subplot(1,2,1)
plot(Y, A-Reconstructed_A);
subplot(1,2,2)
plot(Y, IYY)

Categorías

Más información sobre Performance and Memory en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by