Borrar filtros
Borrar filtros

Error in plotting a function, left and right side with diferent dimensions

1 visualización (últimos 30 días)
When I use this code:
format short
prod_total = zeros(1000, 1);
vet_pedidos = zeros(1000, 1);
x_exp = zeros(1000, 1);
vet_servido = zeros(1000, 1);
for j = 1:1000
a = rng_cheap;
x = a;
if (x <= 0.2)
prod = 1;
elseif (x > 0.2 && x <= 0.6)
prod = 2;
elseif (x > 0.6 && x <= 1)
prod = 3;
end
prod_total(j) = prod;
%
y = 2.8*a + 0.8;
y = y*10;
y = fix(y);
y = y/10;
vet_pedidos(j)= y;
%
x_exp(j) = a;
vet_servido(j) = - (1/2) * log(1- x_exp);
end
[xs, index] = sort(x_total);
ys = vet_total(index);
plot(xs, ys, '-x');
It gives me the following error:
Unable to perform assignment because the left and right sides have a different number of elements.
Error in enunciado8 (line 28)
vet_servido(j) = - (1/2) * log(1- x_exp);
Context: the rng_cheap gives a number.

Respuesta aceptada

Torsten
Torsten el 7 de Mzo. de 2023
Movida: Torsten el 7 de Mzo. de 2023
Most probably,
vet_servido(j) = - (1/2) * log(1- x_exp(j));
instead of
vet_servido(j) = - (1/2) * log(1- x_exp);

Más respuestas (0)

Categorías

Más información sobre Argument Definitions en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by