如何将表中的子集相乘?

发布于 2024-10-20 21:51:02 字数 990 浏览 3 评论 0原文

我有两张表。

一张桌子称为 H,另一张桌子称为 C。两张桌子都是 4 x 3 桌子。

因此如果用户在两个编辑框中插入一个值。例如:

A = *value*
B = *value*

然后用户在H表中插入数据。用户仅使用 2 行。假设这是数据:

      ALPHA   BETA   GAMMA
H1

H2

H3

H4

因此用户想要获取 H1 的子集并与 A 相乘,H2 的子集与 B 相乘。结果如下:

C1 = (ALPHA VALUE)*A  (BETA VALUE)*A  (GAMMA VALUE)*A

C2 = (ALPHA VALUE)*B  (BETA VALUE)*B  (GAMMA VALUE)*B

然后用户想要在 C 表上显示答案变成这样:

            ALPHA        BETA       GAMMA
C1        NEW VALUE    NEW VALUE   NEW VALUE

C2        NEW VALUE    NEW VALUE   NEW VALUE

C3

C4

我怎样才能对这个问题进行编码?

我已经尝试过这个编码,但似乎失败了。任何人都可以帮助我吗?

H = cell2mat(get(handles.Mytable3,'Data'));
cost1 = str2num(get(handles.input2_editText,'String'));

cost2 = str2num(get(handles.input3_editText,'String'));

H1 = H(1,:)*cost1;
H2 = H(2,:)*cost2;
H = mat2cell([H1 H2]);
cost = get(H,'Data');
set(handles.Mytable2,'Data',cost)

I have two figures of table.

One table is call H and another one call C. Both table is 4 by 3 table.

So if the user insert a value in two edit box. For example:

A = *value*
B = *value*

Then the user insert the data in H table. The user only use 2 rows. Let say this is the data:

      ALPHA   BETA   GAMMA
H1

H2

H3

H4

So the user want to get the subset of H1 and multiply with A and subsets of H2 multiply with B. This is how it will be:

C1 = (ALPHA VALUE)*A  (BETA VALUE)*A  (GAMMA VALUE)*A

C2 = (ALPHA VALUE)*B  (BETA VALUE)*B  (GAMMA VALUE)*B

Then the user wants to display the answer on C table where it will become like this:

            ALPHA        BETA       GAMMA
C1        NEW VALUE    NEW VALUE   NEW VALUE

C2        NEW VALUE    NEW VALUE   NEW VALUE

C3

C4

How can i make the coding of this problem?

I have already try this coding but it seems i failed. CAN ANYONE HELP ME PLEASE!!

H = cell2mat(get(handles.Mytable3,'Data'));
cost1 = str2num(get(handles.input2_editText,'String'));

cost2 = str2num(get(handles.input3_editText,'String'));

H1 = H(1,:)*cost1;
H2 = H(2,:)*cost2;
H = mat2cell([H1 H2]);
cost = get(H,'Data');
set(handles.Mytable2,'Data',cost)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掐死时间 2024-10-27 21:51:02

尝试:

H = num2cell([H1 H2]);
set(handles.Mytable2,'Data',H)

Try:

H = num2cell([H1 H2]);
set(handles.Mytable2,'Data',H)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文