fuctions with 40 data lists?

1 次查看(过去 30 天)
prabhu singh
prabhu singh 2022-2-17
i have to write a program where i have 4 data cuboid1,cuboid2,cuboid3,cuboid 4 and each cuboid has length ,breadth and thickness i have write loop in such a way .......when i run this code
it selects one cuboid at a time and when each cuboid is selected ...by default its specification is also selected and later it is checked whether it is conductor or insulator
data={cuboid1,cuboid2,cuboid3,cuboid4);
specifiation cuboid its length breadth and thickness
length=[5 6 7 8 9]
breadth=[5 6 7 8 9]
thickness1=[5 6 7 8 9]
thickness2=[5 6 7 8 9] using for loop
there are two thickness for each cuboid...first it has to take th1 then execute
else th2 execute
  3 个评论
Jan
Jan 2022-2-19
The question is not clear. Where are the "40 data lists"? Why has one cuboid 5 values for length, an breadth and 2 different thickness values?
What is the actual question? Which problem do you want to solve in Matlab?
prabhu singh
prabhu singh 2022-2-20
data={cuboid1,cuboid2,cuboid3,cuboid4);
specifiation cuboid its length breadth and thickness
cuboid1=[length=5,breadth= 6,thickness=9]
cuboid2=[length=7,breadth= 8,thickness=9] like wise its for cuboid3 and 4
how to write in loop using for loop

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2022-2-19
cuboid1 = struct('length', [5 6 7 8 9], 'breadth', [5 6 7 8 9], 'thickness1', [5 6 7 8 9], 'thickness2', [5 6 7 8 9]);
cuboid2 = similar code
data = {cuboid1,cuboid2,cuboid3,cuboid4);
num_cuboids = length(data);
for idx = 1 : num_cuboids
this_cuboid = data{idx};
this_length = this_cuboid.length;
this_breadth = this_cuboid.breadth;
this_thickness1 = this_cuboid.thickness1;
this_thickness2 = this_cubuoid.thickness2;
results(idx,1) = classify_insulation(this_length, this_breadth, this_thickness1);
results(idx,2) = classify_insulation(this_length, this_breadth, this_thickness2);
end
  2 个评论
prabhu singh
prabhu singh 2022-2-20
thank you sir..but after this step i also have to find if results is conductor or insulator.
for example i have assigned conductor=0;
insulator=1;
if result is conductor
then resistivity=1000ohm
a=5;
b=6;
else if insulator
a=5;
b=6
...how can i write code in for loop format......because everything should repeat for 40 cuboids with different length breadth and thickness
(and everytime code has to select one cuboid at a time ..execute all instructions and perfom loop for everything and then follow same routine for 2nd cuboid and so on...)
Walter Roberson
Walter Roberson 2022-2-21
Given the length, breadth, and thickness, how do you figure out whether the object is a conductor or an insulator?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Software Development Tools 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by