필터 지우기
필터 지우기

Analysing Equation in matlab

조회 수: 1 (최근 30일)
Shawaiz Akhter
Shawaiz Akhter 2020년 9월 24일
댓글: Johannes Hougaard 2020년 9월 24일
I am new to matlab and I made a graph of flight score against payload to find apoint where we can get max flight score but i ended up getting blank graph.
This is a code I used. Thank you very much for your time.
nl = [1 , 2];
ns = [2 , 3];
payload = [300 , 400];
x = 1*nl;
y = 0.4*ns;
bonus = [0.5 + (1 *nl) + (0.4 * ns)];
T = [ 5 , 8];
d = payload .* bonus;
e = sqrt(d);
f = 80 * e;
fs = f/T;
plot(fs,payload)
  댓글 수: 1
Johannes Hougaard
Johannes Hougaard 2020년 9월 24일
I think this may well be one of the cases where it's kinda counterintuitive that / doesn't do what you think it does.
the '/' operator (mrdivide) is not identical to the './' operator (rdivide). I believe what you're looking for is the element-wise division (rdivide) and that your code should be
nl = [1 , 2];
ns = [2 , 3];
payload = [300 , 400];
x = 1*nl;
y = 0.4*ns;
bonus = [0.5 + (1 *nl) + (0.4 * ns)];
T = [ 5 , 8];
d = payload .* bonus;
e = sqrt(d);
f = 80 * e;
fs = f./T;
plot(fs,payload)

댓글을 달려면 로그인하십시오.

답변 (1개)

Ollie A
Ollie A 2020년 9월 24일
Be careful when multiplying and dividing arrays; you will need to use the dot notation.
You remembered it for
d = payload .* bonus;
but it is also needed when dividing
fs = f./T;
I also find it helpful to plot data points as crosses:
plot(xdata,ydata,'x')
hold on
plot(xdata,ydata)
that way if you only have 1 data point it will still appear on the plot as a cross.
Also note: if you want flight score on the y-axis and payload on the x-axis, it will be
plot(payload,fs)
  댓글 수: 1
Johannes Hougaard
Johannes Hougaard 2020년 9월 24일
if you like the 'line with cross notation' it's not necessary to call the hold on and a second call to plot you can simple do that by
plot(xdata,ydata,'-x');

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Calendar에 대해 자세히 알아보기

태그

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by