Solved

Newbie help with scatter plots in matlab manually & from the unix command line

Posted on 2010-11-07
11
1,063 Views
Last Modified: 2013-11-25
Ok. referring to question

http://www.experts-exchange.com/Programming/Languages/MatLab/Q_26533273.html#a33881040

How would I

1. input a file called file1.txt which has several columns. The last column of data is predicted values and the second to last column in observed data.

2. create a scatterplot that looks similar to the attached file but with SO2 FCST (PPM) for the Y axis and SO2 OBS (PPM) for the x axis. Also, the domain and range would be based on the data in the input file as opposed to the scatter plot values attached.

3.Create a module (I think thats what it's called) that can be accessed in the future that will simply create a scatterplot using the specifications in step 2 of lets call it module1 with any input file?

4. How would I do this using the a. gui and b. command line within a unix environment?

5. Once the module is created, what would the new command need to be when I enter it in the gui or the command line assuming the module is called module1 and file is called file1 ?


scatterdiag.png
0
Comment
Question by:libertyforall2
  • 6
  • 5
11 Comments
 
LVL 15

Expert Comment

by:yuk99
ID: 34086423
1. It's hard to help without knowing your exact input file format. Please show at least few lines.
In general, for numeric data only you can use DLMREAD function or CSVREAD. For mixed data, TEXTREAD or TEXTSCAN. You can also use LOAD, IMPORTDATA, etc. Do you have Statistical Toolbox, it has other functions for data import? Where the data came from?

2. Once you import the data, use PLOT function:
plot(x,y,'bo')

3. There are no modules in MATLAB, only scripts, functions, classes and toolboxes as packages. What exactly do you need? Tell us how it going to be run. What is the usage workflow.

4. So do you want a GUI or command line. In the first case use GUIDE to create the GUI. It's easy but definitely will be a little hard for a newbie. You will have to read some documentation, follow tutorials, etc. Probably not a matter for a single question.
As for the command line, I think you get the answer in the previous question.


0
 

Author Comment

by:libertyforall2
ID: 34088944
Lets assume the data file would be in the format below. The first column is the date, the second column is the hour, the third is the observed data, and the fourth/last column is the forecast data. The date and time should be ignored. Lets also assume the file is a txt file or perhaps data file.

10-23-2010 02 0.50 0.00
10-23-2010 14 0.02 0.01
10-24-2010 02 0.00 0.05
10-24-2010 14 0.10 0.03
10-25-2010 02 1.00 0.40
10-25-2010 14 0.00 0.01
10-26-2010 02 0.00 0.02
0
 
LVL 15

Expert Comment

by:yuk99
ID: 34094347
Here is the code to input the data and make the plot:
filename = 'in.txt';

[obs fcst] = textread(filename, '%*s %*d %f %f');

plot(obs, fcst, 'bd', 'MarkerSize', 3)

xlim([0 4])

ylim([0 4])

axis square

box off

line(xlim, ylim, 'Color', 'k')

xlabel('PW OBS (C)')

ylabel('PW FCST (C)')

Open in new window

0
 

Author Comment

by:libertyforall2
ID: 34139939
Ok. I need to make sure the forecast range and observation domain for the y & x axis are the same. I may need to adjust them in the future but lets say 25 for so4.txt and 1.00 for so2.txt rounded to whole numbers for so4 or hundredths for so2. How would I write the script for each?
0
 
LVL 15

Expert Comment

by:yuk99
ID: 34147303
To set axes limits you can use xlim/ylim commands. You can also set axes to be square and equal.

xlim([0 25])
ylim([0 25])
axis square

To change ticks you have to pass ticks vector to axes properties XTick and YTick. gca is your current axes handle.

set(gca,'XTick',0:5:25,'YTick',0:5:25)
0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 

Author Comment

by:libertyforall2
ID: 34158238
Ok. I need to force a 45 degree line instead of a trend line within the plot. How would I do this?
0
 
LVL 15

Expert Comment

by:yuk99
ID: 34160055
After to make axes limits the same you can do:

line(xlim, ylim, 'Color', 'k')

or you can set line's coordinates directly:

line([0 25], [0 25], 'Color','k')

See here for different line properties:
http://www.mathworks.com/help/techdoc/ref/line_props.html
0
 
LVL 15

Expert Comment

by:yuk99
ID: 34160063
BTW, all of this were in my original comment: http:#34094347
0
 

Author Comment

by:libertyforall2
ID: 34199287
I am still having difficulties but I will try again.
0
 
LVL 15

Accepted Solution

by:
yuk99 earned 500 total points
ID: 34199699
Do you get errors or just don't know how to do something? Post more details here. Show what you are doing and what you get as a result. More details you post, more chance you have to get better answer.


0
 

Author Closing Comment

by:libertyforall2
ID: 34254127
ok
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Losing network connectivity 8 76
Sonicwall TZ 205- Dropping Incoming E-mail as IP Spoof 13 95
Shoretel Edge Gateway 5 44
Cisco 5508 controller parsing error 4 19
If you're not part of the solution, you're part of the problem.   Tips on how to secure IoT devices, even the dumbest ones, so they can't be used as part of a DDoS botnet.  Use PRTG Network Monitor as one of the building blocks, to detect unusual…
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now