Azzera filtri
Azzera filtri

fuctions with 40 data lists?

1 visualizzazione (ultimi 30 giorni)
prabhu singh
prabhu singh il 17 Feb 2022
Commentato: Walter Roberson il 21 Feb 2022
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 Commenti
Jan
Jan il 19 Feb 2022
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 il 20 Feb 2022
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

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 19 Feb 2022
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 Commenti
prabhu singh
prabhu singh il 20 Feb 2022
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 il 21 Feb 2022
Given the length, breadth, and thickness, how do you figure out whether the object is a conductor or an insulator?

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by