Uneven cell multiplication problem

1 次查看(过去 30 天)
Hey guys.
I am struggling to multple two cells, i ask for an input an that only way i know how to save it is through using a cell. I then have to multiply 2 uneven cells with eac other with each other like multiplying a matrix.
function failure_analysis
prompt = {'Ox(Pa):','Oy(Pa):','Txy(Pa):','Angle(Degrees):','S(Pa):','X(Pa):','Xprime(Pa):','Y(Pa):','Yprime(Pa):'};
a = [inputdlg(prompt)]
sij1 = a(1);
sij2 = a(2);
sij3 = a(3);
angle = 45;
S = a(5);
X = a(6);
Xprime = a(7);
Y = a(8);
Yprime = a(9);
sij = [sij1;sij2;sij3];
F6 = 0;
O6 = 0;
T = [cosd(angle).^2 sind(angle).^2 2*cosd(angle).*sind(angle);
sind(angle).^2 cosd(angle).^2 -2*cosd(angle).*sind(angle);
-cosd(angle).*sind(angle) cosd(angle).*sind(angle) (cosd(angle).^2 -sind(angle).^2)]
O = sij*T
The problem happens in the last line of code.
Any help would be appreciated as i have to hand in the code next week monday.
Thanks

回答(1 个)

Ameer Hamza
Ameer Hamza 2020-5-5
You first need to convert the output of inputdlg from char array to double. Try the following code
prompt = {'Ox(Pa):','Oy(Pa):','Txy(Pa):','Angle(Degrees):','S(Pa):','X(Pa):','Xprime(Pa):','Y(Pa):','Yprime(Pa):'};
a = inputdlg(prompt)
a = cellfun(@(x) str2double(x), a);
sij1 = a(1);
sij2 = a(2);
sij3 = a(3);
angle = 45;
S = a(5);
X = a(6);
Xprime = a(7);
Y = a(8);
Yprime = a(9);
sij = [sij1 sij2 sij3];
F6 = 0;
O6 = 0;
T = [cosd(angle).^2 sind(angle).^2 2*cosd(angle).*sind(angle);
sind(angle).^2 cosd(angle).^2 -2*cosd(angle).*sind(angle);
-cosd(angle).*sind(angle) cosd(angle).*sind(angle) (cosd(angle).^2 -sind(angle).^2)]
O = sij*T

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by