MATLAB Data Generation Algorithim
clc
clear
N=input('Enter Number of Colums = ')
display('Number of colums entered')
M=input( 'Enter Number of rows = ')
display('Number of rows entered')
pause(1)
for j=1:N;
for i=1:M;
x(i,j)=randn(1,1);
end
end
display('The Generated Matrix')
x
save('pqfile.txt', 'x', '-ASCII' )
open pqfile.txt
pause(2)
display('Enter required colum number to plot')
NN=input('Enter Number of Colums = ')
display('Enter required row number to plot')
MM=input('Enter Number of Colums = ')
plot(x(NN,:),x(:,MM),'*-')
title('Plotting Data')
xlabel('Selected Colum')
ylabel('Selected Row')
legend('Data')
grid on
clear
N=input('Enter Number of Colums = ')
display('Number of colums entered')
M=input( 'Enter Number of rows = ')
display('Number of rows entered')
pause(1)
for j=1:N;
for i=1:M;
x(i,j)=randn(1,1);
end
end
display('The Generated Matrix')
x
save('pqfile.txt', 'x', '-ASCII' )
open pqfile.txt
pause(2)
display('Enter required colum number to plot')
NN=input('Enter Number of Colums = ')
display('Enter required row number to plot')
MM=input('Enter Number of Colums = ')
plot(x(NN,:),x(:,MM),'*-')
title('Plotting Data')
xlabel('Selected Colum')
ylabel('Selected Row')
legend('Data')
grid on
The saved data file opened automatically from the saved file
Assign one row and one column
The plotted output for one column and one row:
Unless otherwise noted, all content on this site is @Copyright by Ahmed Al Makky 2012-2013 - http://cfd2012.com