필터 지우기
필터 지우기

fuctions with 40 data lists?

조회 수: 1 (최근 30일)
prabhu singh
prabhu singh 2022년 2월 17일
댓글: Walter Roberson 2022년 2월 21일
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에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by