フィルターのクリア

Urgent!! Matlab help needed on structures

2 ビュー (過去 30 日間)
newiuht
newiuht 2012 年 2 月 11 日
Command window:
parts =
1x3 struct array with fields: partno quantity costper
>> parts(1)
ans =
partno: 123
quantity: 4
costper: 33
>> parts(2)
ans =
partno: 142
quantity: 1
costper: 150
>> parts(3)
ans =
partno: 106
quantity: 20
costper: 7.5000
I need help with writing a general code that will, for any values and any number of structures in the variable parts, print the part number and the total cost (quantity of parts multiplied by the cost of each) in a column format.
For example, if the parts stores the prevuos values, the result would be:
123 132.00
142 150.00
106 150.00
  1 件のコメント
Walter Roberson
Walter Roberson 2012 年 2 月 27 日
http://www.mathworks.com/matlabcentral/answers/29922-why-your-question-is-not-urgent-or-an-emergency

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2012 年 2 月 11 日
Provided that the part numbers are numeric as shown, then:
[vertcat(parts.partno), vertcat(parts.quantity) .* vercat(parts.costper)]

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by