Matrix Division - Why am I getting a 1x1 matrix after dividing two 1x13 matrices?

조회 수: 1 (최근 30일)
Hello there,
I am trying to plot three different curves that are functions of the same variables to try and compare the three in terms of their output (the three equations are yield models - poisson, and two Murphy's yield model equations). I have used the following as my code:
A = 0.000036:0.000001:0.000048 ; %Die Area = 36 mm^2, now converted to m^2%
D = 7000; %Defect density = 0.7/cm^2 now converted to defects/m^2%
y_poisson = exp(-A*D);
plot(A,y_poisson) %plots the poisson yield model%
hold on
y_MurphyFirst =(1 - exp(-2*A*D))/(2*A*D);
plot(A,y_MurphyFirst) %plots the Murphy's First equation yield model%
y_MurphySecond = ((1 - (exp(-A*D)))/(A*D))^2;
plot(A,y_MurphySecond) %plots the Murphy's Second equation yield model%
hold off
After running that code, only the first plot for y_poisson plots, the other two, y_MurphyFirst and y_MurphySecond appear as 1x1 matrices in the workspace hence I get no plot. Am thinking that the problem is with my division in
y_MurphyFirst =(1 - exp(-2*A*D))/(2*A*D);
and
y_MurphySecond = ((1 - (exp(-A*D)))/(A*D))^2
I'd appreciate some help in writing the two equations in their correct matlab sytax. The two equations are: Y = (1 − ?^(−2??))/2?? and
Y = ((1 − ?^(−??))/A?)^2 respectively.
Thanks in advance!

채택된 답변

Guillaume
Guillaume 2020년 1월 20일
The / operator solves a system of linear equation. If you want to perform elementwise division you need to use the dotted operators:
y_MurphyFirst =(1 - exp(-2*A*D))./(2*A*D);
y_MurphySecond = ((1 - (exp(-A*D)))./(A*D))^2

추가 답변 (1개)

Bhaskar R
Bhaskar R 2020년 1월 20일
You have used operatot "/". Here you need to perform elemtwise operation "./" and ".^"
A = 0.000036:0.000001:0.000048 ; %Die Area = 36 mm^2, now converted to m^2%
D = 7000; %Defect density = 0.7/cm^2 now converted to defects/m^2%
y_poisson = exp(-A*D);
plot(A,y_poisson); %plots the poisson yield model%
hold on
y_MurphyFirst =(1 - exp(-2*A*D))./(2*A*D);
plot(A,y_MurphyFirst) %plots the Murphy's First equation yield model%
y_MurphySecond = ((1 - (exp(-A*D)))./(A*D)).^2;
plot(A,y_MurphySecond) %plots the Murphy's Second equation yield model%
hold off

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by