Uneven cell multiplication problem

2 views (last 30 days)
John Spencer De Wit
John Spencer De Wit on 5 May 2020
Commented: Ameer Hamza on 6 May 2020
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

Answers (1)

Ameer Hamza
Ameer Hamza on 5 May 2020
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

Categories

Find more on Programming in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!