Uneven cell multiplication problem

2 vues (au cours des 30 derniers jours)
John Spencer De Wit
John Spencer De Wit le 5 Mai 2020
Commenté : Ameer Hamza le 6 Mai 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

Réponses (1)

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

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by