Command for perfect matrix multiplication. Command gives perfect size of matrix

2 次查看(过去 30 天)
Ts
Ts(:,:,1) =
0.5000 0.5000 1.0000
0.5000 0.5000 -1.0000
-0.5000 0.5000 0
Ts(:,:,2) =
0.5000 0.5000 1.0000
0.5000 0.5000 -1.0000
-0.5000 0.5000 0
Ts(:,:,3) =
1 0 0
0 1 0
0 0 1
Ts(:,:,4) =
1 0 0
0 1 0
0 0 1
Ts(:,:,5) =
1 0 0
0 1 0
0 0 1
L
L(:,:,1) =
1.0e-04 *
0.1215
0.1215
-0.2570
L(:,:,2) =
1.0e-04 *
0.1215
0.1215
-0.2570
L(:,:,3) =
1.0e-04 *
-0.0070
0.2500
0
L(:,:,4) =
1.0e-04 *
-0.0070
0.2500
0
L(:,:,5) =
1.0e-04 *
-0.0070
0.2500
0
STs
STs(:,:,1) =
1.0e-07 *
-0.3210 -0.3210 0.6015
STs(:,:,2) =
1.0e-07 *
-0.3210 -0.3210 0.6015
STs(:,:,3) =
1.0e-07 *
-0.0203 -0.6218 0
STs(:,:,4) =
1.0e-07 *
-0.0203 -0.6218 0
STs(:,:,5) =
1.0e-07 *
-0.0203 -0.6218 0
>> If i using bsxfun(@times, Ts,L); it gives wrong size of matrix. i need command for [3*3]*[3*1] gives [3*1] matrix. [1*3]*[3*1] gives [1] value. please tell command for array multiplication for every size.[3*1]*[1*3] give[3*3].

采纳的回答

Walter Roberson
Walter Roberson 2015-10-31
编辑:Walter Roberson 2015-11-1
temp = arrayfun(@(J) Ts(:,:,J)*L(:,:,J), 1:size(Ts,3), 'Uniform', 0);
STs = cell2mat(reshape(temp,1,1,[]));
  5 个评论
Walter Roberson
Walter Roberson 2015-11-1
Not unless you do a lot of work to define STs in terms of a class that gives the units as part of the display.
I do not understand what you mean by "it's disp stands out". You asked "after every STs(:,:,i) show N/m^2" and that is what you get. For example,
STs(:,:,1) = N/m^2
0.188001526199785 0.11424886510142 0.107687728046081
0.111973001256813 0.222441422169407 0.362939604152811
0.626849792977697 0.312785095840677 0.200911101587562
STs(:,:,2) = N/m^2
0.622262777115983 0.327396680058041 0.421739252162982
1.17195405095794 0.45294485413646 0.612747199403293
1.56288846761804 0.486662493250459 0.700386125146523
After every STs(:,:,i) it displays N/m^2 like you asked.
Do you mean that after every value you would like N/m^2 ? If so then it requires a class to have it printed automatically, but you can code
fmt = repmat('%10g N/m^2 ', 1, size(STs,2));
fmt(end:end+1) = '\n';
for P = 1 : size(STs,3)
fprintf('\nSTs(:,:,%d) =\n', P);
fprintf(fmt, STs(:,:,P).');
end
Triveni
Triveni 2015-11-1
Sorry i bothering you...but my question is when is press STs in command window it should display
STs(:,:,1) = N/m^2
0.188001526199785 0.11424886510142 0.107687728046081
0.111973001256813 0.222441422169407 0.362939604152811
0.626849792977697 0.312785095840677 0.200911101587562
STs(:,:,2) = N/m^2
0.622262777115983 0.327396680058041 0.421739252162982
1.17195405095794 0.45294485413646 0.612747199403293
1.56288846761804 0.486662493250459 0.700386125146523
units are showing only for running or first time. i want to present it each time when i press STs. Thanks

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by