i want to solve X+Y+Z=10 and 0<x<10, 0<y<10, 0<z<10 want each combination value of x,y and z in full digit

1 次查看(过去 30 天)
for value of x,y and z satisfy that equation and x, y and z in this range and answer in full digit in matlab than give answer in matlab code

采纳的回答

Walter Roberson
Walter Roberson 2016-11-21
You do not have enough memory on your computer to store all of the combinations. There are 4607182418800017407 distinct values that can be represented in the range 0 <= x < 1 alone.

更多回答(1 个)

KSSV
KSSV 2016-11-21
x = 0:10 ;
y=x ;
z = x ;
[X,Y,Z] = ndgrid(x,y,z) ;
thesum = X+Y+Z ;
% get equal to 10
idx = thesum==10 ;
iwant = [X(idx) Y(idx) Z(idx)]

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by