Uneven cell multiplication problem

2 visualizzazioni (ultimi 30 giorni)
John Spencer De Wit
John Spencer De Wit il 5 Mag 2020
Commentato: Ameer Hamza il 6 Mag 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

Risposte (1)

Ameer Hamza
Ameer Hamza il 5 Mag 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
  2 Commenti
John Spencer De Wit
John Spencer De Wit il 6 Mag 2020
Thanks it works perfectly
Ameer Hamza
Ameer Hamza il 6 Mag 2020
I am glad to be of help.

Accedi per commentare.

Categorie

Scopri di più su Programming in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by