How to plot a line graph with algebraic function

2 views (last 30 days)
i have this equation y = -3.546x^4 + 40.652x^3 - 172.24x^2 + 320.58x - 221.62 i dont know how to plot it all i can get is like a wave graph. i cant get it to be curved graph. please help me
  2 Comments
Geoff Hayes
Geoff Hayes on 30 Dec 2015
Mukri - please clarify what you mean by I can't get it to be a curved graph. What values of x are you using? What is the code that you have written to plot the curve? Please attach an image of what you are observing (the wave) and what you wish to see (the curve).
Mukri Ramli
Mukri Ramli on 1 Jan 2016
the graph should not have -ve value please refer to my coding i want to use the value of Y_scaled to put inside the value of x.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 1 Jan 2016
r = -3.546*Led.^4 + 40.652*Led.^3 - 172.24*Led.^2 + 320.58*Led - 221.62;
plot(Led, r)

More Answers (1)

dpb
dpb on 30 Dec 2015
Try
ezplot('-3.546*x^4 + 40.652*x^3 - 172.24*x^2 + 320.58*x - 221.62') % let if default
ezplot('-3.546*x^4 + 40.652*x^3 - 172.24*x^2 + 320.58*x - 221.62',[-100 100]) % force wide range
and see if can't then tell over what range of independent variable you're interested.
  1 Comment
Mukri Ramli
Mukri Ramli on 1 Jan 2016
Edited: Walter Roberson on 1 Jan 2016
i still cant get the line graph that i want.
my x value cant be read.
the graph does not produce
this is my coding
% OFDM system, Transmitter
%
% OFDM system parameters:
% N : size of OFDM symbol assuming fully loaded symbol
% M : constellation order size (Alphabet size)
% P or Q : PSK or QAM mapping = 1 means PSK and 2 means QAM
% Symbol Order: constellation Symbol Order {1 for Binary and 2 for Gray}
% Ncp : size of cyclic prefix samples
% m : Number of bits OFDM symbols to be simulated
clear;close all;clc;
Initializing parameters
OFDM.N=input('Size of OFDM Symbol N = '); %No of FFT Bin
OFDM.m=input('Number of bits OFDM symbols to be simulated m = '); %No of data points
OFDM.M=input('Constellation size M = '); %Constellation
OFDM.PoQ=input('Type of Mapping (1 for PSK) and (2 for QAM) = '); %Modulation Type
OFDM.Symbol_Order=input('constellation Symbol Order (1 for Binary) and (2 for Gray) = '); %Binary
OFDM.Ncp=input('size of cyclic prefix samples Ncp = '); %
%%Transmitter
% Creating Baseband modems Tx
if OFDM.Symbol_Order == 1
OFDM.Symbol_Order = 'binary';
else
OFDM.Symbol_Order = 'gray';
end
if OFDM.PoQ == 1
hTx = modem.pskmod('M',OFDM.M,'SymbolOrder',OFDM.Symbol_Order);
else
hTx = modem.qammod('M',OFDM.M,'SymbolOrder',OFDM.Symbol_Order);
end
%---------------------------------------------------------------------------------------
% data generation
%OFDM.DATA=randi([0 OFDM.M-1],OFDM.m,OFDM.N);
OFDM.DATA=randi([0:1],OFDM.m,1); % Create a binary sequence of 0 & 1 with OFDM.m bits
figure(1);
stem(OFDM.DATA);
title('Binary Input Signal');
xlabel('Bit Index')
ylabel('Binary Value')
%----------------------------------------------------------------------------------------
% Serial to Parallel
%OFDM.parallel=OFDM.DATA.';
%Convert the random bits into words with log2(M) size
%returns the OFDM.parallel where the elements are taken form
OFDM.parallel_bin =reshape(OFDM.DATA,log2(OFDM.M),length(OFDM.DATA)/log2(OFDM.M));
%d=bi2de(b,p) converts a base-p row vector b to a nonnegative decimal
%integer, where p is an integer greater or equal than or equal to 2,
%flag = rightMSB of leftMSB, leftMSB where the data stream is flipped and
%further left bit is MSB.
OFDM.parallel=bi2de(OFDM.parallel_bin.','left-msb');
%figure(2); %Create new figure window
%stem(OFDM.parallel);
%title('Random Symbols');
%xlabel('Symbol Index');
%ylabel('Integer Value');
%---------------------------------------------------------------------------------------
% Mapping and Modulation
OFDM.qam_modulate = modulate(hTx,OFDM.parallel);
%figure(4);
%scatterplot(OFDM.qam_modulate(4:end),1,0,'k*');
%title('Modulation');
%legend('Mapping');
%axis([-5 5 -5 5]);
%-----------------------------------------------------------------------------------------
% Find out the number of colums(bins) that will exist after reshaping
num_cols=length(OFDM.qam_modulate)/OFDM.N;
% Create empty matix to put the IFFT'd data
data_matrix = reshape(OFDM.qam_modulate, OFDM.N, num_cols);
% Execute IFFT (with Hermitian Symmetry) for each bins
for i=1:num_cols,
OFDM.IFFT(:,i) = ifft((data_matrix(:,i)),OFDM.N,'symmetric');
end
%figure (5);
%stem(real(OFDM.IFFT));
%xlabel('bins');
%ylabel('Amplitude)');
%title('ifft data(real)'); grid on;
%figure (6);
%stem(imag(OFDM.IFFT));
%xlabel('bins');
%ylabel('Amplitude ');
%title('ifft data(imaginary)'); grid on;
%---------------------------------------------------------------------------------------------------
% Parallel to serial
%ofdm.serial=ofdm.am;
[rows_ifft_data cols_ifft_data]=size(OFDM.IFFT); %[m,n] = size(x) returns the size of matrix X in seperate variables m*n
len_ofdm_data = rows_ifft_data*cols_ifft_data; %calculate the length of a serial data based on rows and columns
OFDM.serial = reshape(OFDM.IFFT, 1, len_ofdm_data);
%figure(7)
%stem(OFDM.serial); xlabel('Time'); ylabel('Amplitude');
%title('OFDM Signal');grid on;
Cyclic Prefixing
ofdm.CP_part = [OFDM.serial(:,end-OFDM.Ncp+1:end)]; % this is the Cyclic Prefix part to be appended.
size(ofdm.CP_part)
ofdm.signal=[ofdm.CP_part OFDM.serial];
%figure(8);
%stem(ofdm.signal);xlabel('Time'); ylabel('Amplitude');
%title('OFDM Signal with Cyclic Prefix');grid on;
DC bias Add value of 3.1V to each bit
Y =(ofdm.signal+3.1);
%figure(9);
%size(Y);
%plot(Y);
%title('DC bias');
%xlabel('bits');
%ylabel('volt');
%Scalling the graph
Y_scaled = (Y-min(Y))*(3.2-3)/(max(Y)-min(Y)) + 3;
figure(10);
plot(Y_scaled);
title('DC bias Scaled');
xlabel('bits');
ylabel('volt');
%LED
%Using OSRAM datasheets as the reference of the LED frequency and
%specification, the graph of LightVsVoltage is obtain using its normalized
%frequency.
figure(11);
Led = Y_scaled;
ezplot('-3.546*Led^4 + 40.652*Led^3 - 172.24*Led^2 + 320.58*Led - 221.62') % let if default
ezplot('-3.546*Led^4 + 40.652*Led^3 - 172.24*Led^2 + 320.58*Led - 221.62',[0 4]) % force wide range
title('Light vs Voltage');
xlabel('Voltage');
ylabel('Light-OpticalPower(Mw)');
i just need to produce the figure 11 graph to show that the signal passes through LED.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!