need help creating a vector and and plotting

14 views (last 30 days)
Hello All,
Like many others, I am in need of assistance for a project I'm working on. I myself do not know what the issue is, my partner is also unsure, nor are my cohorts, and my professors chooses not to look at my code, which effectively neutralizes my immediate help. So anyway...
Some may notice, I have posted a similar thread on the newsgroup page. I apologize, I know this is not correct etiquette, however with deadlines so close, I don't have the luxury of waiting through the proper channels.
My assignment is to plot a contour of the salton sea and then plot salinity, elevation and exposed shore after x number of years.
So after finding the contour points, I made a single excel sheet to hold all the points. To provide an example, I had x y and z points. lets say x1, x2, x3, y1, y2, y3 and z1, z2, z3. Due to the irregular shape of the salton sea, all the values may be irregular themselves. x1 may have two points (1 and 5) x2, 3 (2, 4, 6,) and x3 5 points , (1, 0, 9, 2, 3) because they are tripled. y and z would have the same number of points of their respective triplets, i.e. x1, y1, z1 have two points, x3,y3,z3 have five.
When the excel spread sheet is read into matlab, each entry is read as a column vector.
then in my actual code, I use plot 3 to plot all the triplets eg. plot3 (x1, y1, z1) and then I hold on to plot the remaining points.
I then initialize approrpriate variables, and create empty vectors to store the data, of salinity, elevation etc...
I then use for loops to calculate the data and store them in the appropriate vectors.
I then want to create a figure to plot my other data since the map finished. the section of code is
createfigure(X1, Y1, Y2)
figure1 = figure('Name','Salinty & Elevation vs Time');
axes1 = axes('Parent',figure1,...
'YTickLabel',{'100','120','140','160','180','200'},...
'YTick',[100 120 140 160 180 200],...
hold(axes1,'all');
% Create plot
plot(X1,Y1);
During this part I get an error. Something that X1 Y1, and Y2 is undefined
I thought they were vectors were already defined since I created the empty vector and had imported column vectors data.
I'm sorry if this is vague. I want to post the full code; however, my prof is going to use a plagiarism check. I don't want to have a chat with my prof over possible plagiarism since its my own code.
For those who can help me and want to see my entire code, send me a message.
Of course, you should post a message in this thread too, so I can give you your earned best answer.
Cheers.

Answers (1)

Star Strider
Star Strider on 7 Dec 2014
First, rest easy. There is no hierarchy with respect to the newsgroup (CS_SM) and MATLAB Answers. Some of us only surf one (I only surf Answers, for instance).
Second, the problem you are encountering is that MATLAB is case-sensitive, so x1~=X1, etc., and x1 and X1 are distinct variables.
  4 Comments
Reginald
Reginald on 8 Dec 2014
Edited: Reginald on 8 Dec 2014
To avoid plagiarism I writing this down. Creator: revan009 course: Engr 118 Instructor: BMWong Ph.D.
so, before you start the program, you load the excel data into the program. in my current version, the excel data is being read as column vectors.
figureU = figure('Name','Ssea countor');
plot3(x0,y0,z0)
hold on
plot3(x1,y1,z1)
hold on
plot3(x2,y2,z2)
hold off
title('Ssea contour')
F1 = 151020;
F2 = 166020;
F3 = 151020;
Min1 = 3833485.5;
Min2 = 3818485.5;
Min3 = 3803485.5;
Vint = 7000000;
Mint = 60.6543*7000000;
Confac = 0.375466848;
w = [];
x = [];
y = [];
z = [];
for t = 0
V = Vint + F1;
Vint= V;
M = (Mint + Min1);
Mint = M;
C = (Mint/Vint)*ConFac;
h = -exp((6.28511211e-42)*(Vint^6) - (1.91992448e-34)*(Vint^5) + (2.26834756e-27)*(Vint^4) - (1.30678922e-20)*(Vint^3) + (3.86777924e-14)*(Vint^2) - (7.94923730e-08)*(Vint) + 5.62272556);
Sa = (34341590-(((-0.00008044373)/7)*(h^7) - ((0.1127622)/6)*(h^6) - ((65.73068)/5)*(h^5) - ((20394.69)/4)*(h^4) - ((3552542)/3)*(h^3) - ((329392400)/2)*(h^2) - ((12700140000)*h) - 418778818034.047))/43560;
w(end+1)=Sa;
x(end+1)=t;
y(end+1)=C;
z(end+1)=h;
end
createfigure(X1, Y1, Y2)
figureU = figure('Name','Salinty & Elevation vs Time');
% Create axes
axes1 = axes('Parent',figure1,...
'YTickLabel',
{'0','40','60','80','100','120','140','160','180','200','220'},...
'YTick',[20 40 60 80 100 120 140 160 180 200 220],...
'YColor',[0 0 1]);
hold(axes1,'all');
% Create plot
plot(X1,Y1,'Parent',axes1,'Marker','o');
xlabel('Time (years)');
% Create ylabel
ylabel('Salinity ','Color',[0 0 1]);
axes2 = axes('Parent',figure1,...
'YTick',[-260 -255 -250 -245 -240 -235 -230 -225],...
'YAxisLocation','right',...
'YColor',[1 0 0],...
'ColorOrder',[0 0.5 0;1 0 0;0 0.75 0.75;0.75 0 0.75;0.75 0.75 0;0.25
0.25 0.25;0 0 1],...
'Color','none');
hold(axes2,'all');
plot(X1,Y2,'Parent',axes2,'Marker','o','Color',[1 0 0]);
ylabel('Elevation (ft)','VerticalAlignment','cap','Color',[1 0 0]);
title({'Salinty & Elevation vs Time'});
createfigure(X1, Y1)
figureU = figure('Name','Exposed Shoreline Area vs Time');
axes1 = axes('Parent',figure1,'YTick',[250 300 350 400 450 500 550 600 650]); hold(axes1,'all');
plot(X1,Y1,'Marker');
title('Exposed Shoreline');
xlabel('Time ');
ylabel('Shoreline');
Star Strider
Star Strider on 8 Dec 2014
I don’t see where you read in your .xlsx file and assigned ‘x1’, ‘X1’ and the others. That seems to be where the problem is.
Please provide the lines where you read in your file and assign the variables.

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!