**Q: I'm having trouble getting two different colormaps to display in the same figure.****Q: data file loading problems***Q:problems plotting when running matlab remotely**Q: errors reading data files**Q: Which data files do we need to filter? How many custom color maps do we need to make?**Q: I have a PowerPC Mac and I was just wondering if you knew what I could do in order to be able to download Matlab?**Q: How should we do the commenting of matlab script files? Should we have more than one file, or one big one?**Q: I don't understand how to write a script to perform a high pass filter for the sounddata assignment. How do I derive it from the low pass filter file that's posted online?**Q: For parts 1 and 2, do we just need to print the plots, or do we need to print the matlab commands we used to generate the plots?**Q: For part 2, you ask if the execution time for the recursive filter changes when you change the value of a. Does that mean we're supposed to use both the recursive and the moving average algorithms for low pass filtering? Should we have two plots, one for each algorithm? Should we also use both algorithms for high pass filtering?**Q: For part 2, the homework says we should experiment with window sizes to find one which removes the high frequency components. However, the sound file seems to be made up of many different frequencies of waves. Which ones count as the "high" ones? The very highest ones?**Q: You mentioned in class there was something to read about how to optimize the matlab code (for the bonus points). Where was that again?**Q: When you asked us to plot all the data sets, did you want us to plot the two sets in Set1 together (as in x=Set1a and y=Set1b) or each individually?**Q: I can't figure out how to plot Set 4. Help!**Q: I have been trying to plot the large data set using the commands you reccomend in the homework, but all I get are black and single colored lines.**Q: You ask in Part II whether time changes for a value of a. What do you mean by 'a'?**Q: I am a little bit unclear as to how I make a colormap. The help*

colormap explained the theory behind a colormap and I understand that, but

how do I actually make one. Is it a .m file or do I just type numbers into

the command page?*Q: I just want to make sure I am using the sound data correctly. I*

multiplied Fs (which was just the single number 44100) by ys and formed a

new variable. I then plotted this new variable.*Q: When you say "load the data sets into a*

variable of your choice, such as data, one variable per data file," how do

you want want us to combine multiple variables in one file?*Q: Every time I try to do pcolor, surf, or mesh Matlab crashes. Do I just have a curse or what?**Q: Now about the high pass, I still don't get it. Am I supposed to put, " x_HP = x - x_LP ;" in the editor/script thing (Low_Pass.m) or in the command window. The same for, " function x_HP = High_Pass( x, window_size );" And if it is in the Low_Pass.m file, where exactly would it go?**Q: What is the equation for the recursive filter?*

**Q: I'm having trouble getting two different colormaps to display in the same figure. **

*A: There are a few ways to go. Check this out (here's the mathworks help file to look at - http://www-ccs.ucsd.edu/matlab/techdoc/umg/chaxes16.html3):
Another way to do it is like this (requires downloading another function from mathworks, which is free)
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=7943
You could also do a web search for this type of thing. Matlab only allows one colormap per figure. Sorry about the confusion. If you can't get either of these two methods to work, use separate figure windows and put them together in another program (like word or photoshop) after saving them as an image file.*

**Q: We're having trouble getting the data files to load. We've looked up the 'load' function in the MATLAB pdf tutorial that you've provided us and we still keep getting error messages. Also, we can't figure out how to open all 6 data sets into one MATLAB window.**

*A: First of all you will load the data into separate variables (each data set has variables of different names already, but I would recommend loading one in at a time, doing all the plots for that one, then clearing memory with a clear all command). You should be able to load the data, after you unzip it into the separate files by using the load command such as :
load hw2dataset1.mat
or
load hw2dataset1
but remember you have to have the matlab work directory the SAME directory as your data files, or it needs to have that directory permanently added. You can change the directory by using cd at the command prompt and getting to your folder, and ls to list the files in the current directory, or you can click the button with the three dots ('...') next to the display at the top of your window which shows the current work directory.
IF all this is really confusing or you are having problems, the easy way to change your work directory is to create an m-file by clicking file-new-m_file, do some trivial calculation, then save the m-file into the directory your data is in and run it. That will get matlab to change it's work directory to that folder. If this is not your problem, let me know what your errors are and we'll go from there.*

*Q: I did have Cygwin installed successfully to my laptop by following the instruction page and such. one thing though is when i logged into the terminal and when after i sped through all the announcements and stuff , at the very buttom right b4 where i type in commands, there will be like 2 lines saying stuff like " you will not be able to use graphic functions or plotting " stuff like that..
it's weird cause all other functions are seemingly intact it's just somehow seems like they kind of shut off the graph/plotting part...How do I get matlab to show plots when logging in remotely?*

*A: First of all, read the tutorial for doing this here. If that still doesn't answer your question then read on*

* You don't want to launch the cygwin shell program. Instead launch x11 by finding and double-clicking the startxwin.bat file. Wait a few moments, then from the window that comes up, then type the ssh command as follows:
ssh icogsci1.ucsd.edu -X -l yourlogin
Then press return, and when prompted, enter your password. The -X is very key, as that is what forwards the display data to your screen.
Press space bar until all the ssh login information text all stops scrolling and you get back to the command prompt. Now the fix I suggested was for solving problems with matlab running too slowly remotely. If you just want to save graphics, I suggest you launch matlab by, instead of typing 'matlab' to launch it, typing 'matlab -nojvm' . Now what that does is you'll see matlab run in the text window, but plots will appear on your screen when you plot them.
The other fix I noted was the changing of that link to the cygwin/x installer manual. It was going to the cygwin manual, which doesn't tell you which exact packages to install. Now that link is fixed.
Hope that works. Again if you can't get this working, just save the plots to a file directly using the print command, then use an ftp program such as smartftp (which is free from www.smartftp.com) to download the files to your computer from your remote account space.*

**Q: I tried loading the data sets that were on the coursewebsite and it
wouldn't load and said the data was corrupt... which shouldn't be the case
because everyone else were loading it just fine.
I run Matlab 6 on my laptop, could this not be compatible witht he data
sets???
If so, is there a good way to get Matlab 7 without shelling out $500?**

*A: I've re-loaded the data, so matlab versions from v4 on should now be able to load the data files. Please let me know if there are still problems.*

*Q: Just to be clear, we only have to create a custom color map for largeset.mat and only have to create filters for sounddata.mat. And for the other 4 data sets, we just have to plot them and comment on their apperances. Is this correct?*

*A:There's a second filtering problem, one of the other data sets. It's a periodic signal. Just the one custom color map on largeset.mat*

*Q:I have been trying to find and download matlab onto my apple computer. I have an iMAC G5 (desktop) and I was just wondering if you knew what I could do in order to be able to download the software. I know you spoke about the the Beta file for the intel based mac but I cant really recall what that is/does again and if I need that version or not. *

*A: the beta is unfortunately only for intel-based macs I think. So your G5 is not an intel mac, it is a powerPC. This refers to the CPU type. So if you are off campus you should do the remote login method. Let me know if there are problems there.*

*Q:How should we do the commenting on the scripts. Should we copy and paste
all the scripts/commands from matlab in one mfile and then comment on them
there?*

*A: In terms of commenting on the scripts, you can either make separate files or one big script file. It's up to you. Remember you create a comment by a % sign*

*Q: I don't understand how to write a script to perform a high pass filter for the sounddata assignment. How do I derive it from the low pass filter file that's posted online? Please give me some guidance*

*A: The simple way to make a high pass filter is to make a function that first finds a low pass filtered version of the data, then subtracts that from the original data. That leaves the high frequency components of the data remaining. Also note that you can call functions from within functions in matlab. So the equation, after getting the low pass filtered data into a variable x_LP (or something) might look like
x_HP = x - x_LP ;
Ta-Da! So I'd create another script file called High_Pass.m or something similar, and you can do two things from here, one would be copy the low pass filter code into that code so it computes it right in your high pass filter function, or just have the high pass filter code call the low pass filter code to compute that part, then perform the above calculation and return the high pass filtered data. You might want to also let the user set the window size of the low pass filter when calling the high pass filter by adding another input variable like this when defining your function:
function x_HP = High_Pass( x, window_size );
I'm going to put together a little filtering handout for the class since I haven't been able to work some details of filtering into the lectures even though I spent two lectures on filtering. That should clear up some details for people, but that info isn't necessary for this homework exactly. *

*Q:For parts 1 and 2, do we just need to print the plots, or do we need to print the matlab commands we used to generate the plots?*

*A: You need to create a matlab script which is well commented that contains the commands you used for each problem, in addition to the prints*

*Q: For part 2, you ask if the execution time for the recursive filter changes when you change the value of a. Does that mean we're supposed to use both the recursive and the moving average algorithms for low pass filtering? Should we have two plots, one for each algorithm? Should we also use both algorithms for high pass filtering?*

*A: Yes, you should use both types of low pass filters. I want you guys to get a sense of the difference, and do some timing experiments (tic-toc commands). You need either separate plots or plot the data in the same window with different colors and linetypes. For high pass, I'm not sure I asked for that. Just revert to what was asked for. If I didn't say, then you don't have to do both. *

*Q: You mentioned in class there was something to read about how to optimize the matlab code (for the bonus points). Where was that again?*

*A: Go to matlab help, then click the contents tab, and the matlab drop down, then go to programming- improving performance and memory usage.*

*Q: When you asked us to plot all the data sets, did you want us to plot the two sets in Set1 together (as in x=Set1a and y=Set1b) or each individually?*

*A: For set 1, you could either plot them separately as one plot for a and one for t, or plot them as plot(t,a). Otherwise plot the others separately.
*

*Q: I can't figure out how to plot Set 4. Help!*

*A: For set 4 you should have no problem if you get the variable into memory by loading the file, then use pcolor(B) to get a basic visualization.*

*Q: I have been trying to plot the large data set using the commands you reccomend in the homework, but all I get are black and single colored lines. I'm pretty sure this is not what it should look like. I have no idea what I'm doing wrong. I tried looking up what squeeze does, but that didn't explain anything to me.*

*A: For the large data set, some of the slices of the data are blank. Sometimes what happens is that data is encoded that way ('padded' with zeros) because it is being saved as some general format. So try different slices, ie I suggest (HINT HINT HINT) you try the following:
pcolor(squeeze(BigB(:,:,1,2)))
Hmmm....what could that be? Well try changing the numbers a bit and see what you get...try more than three changes...You were probably using Squeeze correctly if you weren't getting errors. It's a matter of exploring what the data contains. This sometimes has to be done, so it's useful to get a sense of now.
*

*Q: You ask in Part II whether time changes for a value of a. What do you mean by 'a'?*

*A: I mean by the strength of the filter coefficient for the low pass filter (the recursive filter, not the moving average). Moving the coefficient towards 0 makes it a stronger low pass filter, because it weighs the filtered previous point more heavily than the current data point.*

*Q: I am a little bit unclear as to how I make a colormap. The help
colormap explained the theory behind a colormap and I understand that, but
how do I actually make one. Is it a .m file or do I just type numbers into
the command page?*

*A: the colormap command uses a 3xn matrix, 'map' which is up to you to create. Each column of the matrix is a color (red, green or blue)
try using the command map=colormap; to look at how some of the built in colormaps work in matlab.
*

*Q: I just want to make sure I am using the sound data correctly. I
multiplied Fs (which was just the single number 44100) by ys and formed a
new variable. I then plotted this new variable.*

*A: you don't need to multiply by Fs. That just tells you that the sampling rate of this data was 44.1kHz (or 44100 samples per second). This would let you make a time axis by creating an array of length(ys) and then dividing it by Fs. For example:*

*time = 1:length(ys);*

*time = time/Fs;*

*Now time is in seconds! Cool*

*Q: When you say "load the data sets into a
variable of your choice, such as data, one variable per data file," how do
you want want us to combine multiple variables in one file? For the first
data set, should I do something like data = [a t] or data = [a;t]? Or is
there something else I should be doing?*

*A: Sorry for the confusion. The intent of that statement was that you should work on one data set at a time. If you try to load all the data sets into one variable life would get complicated unnecessarily. So load that first set, and use the variables given, perform your plots, then clear the memory and work on the next set.*

*Q: Every time I try to do pcolor, surf, or mesh Matlab crashes. Do I just have a curse or what?*

*A: Fear not, put away your anti-math-matlab-programming-curse charms, go to the command prompt and type *

*opengl neverselect*

* then press return. Problem solved. It's a graphics driver issue, so that command bypasses the opengl hardware driver for the graphics card, and uses a software-based approach which is more compatible with windows*

*Q:Now about the high pass, I looked at the hints page, but still don't get it. Am I supposed to put, " x_HP = x - x_LP ;" in the editor/script thing (Low_Pass.m) or in the command window. The same for, " function x_HP = High_Pass( x, window_size );" And if it is in the Low_Pass.m file, where exactly would it go?
*

*A: I think you're over thinking this. It's simpler than you would expect:
1)compute the low pass filtered data and store it in a variable such as x_LP by
x_LP=Low_Pass(x, 100); %or some other number for window size
2) compute the high pass filter by one line:
x_HP = x - x_LP;
So it subtracts the low frequencies from the original data. Think about it this way:
total data frequencies = (low frequency part of data) + (high frequency part of data)
so you could get the high frequencies by simple algebra:
(high frequency part of data) = (total data frequencies) - (low frequency part of data)
3)I would do this in a command window or script file. It should not be done in the same script file as the low pass filter function file. That is set, and you don't need to change it once you wrote it (or downloaded the example). You just call to it from another script or the command line. Think of it like the plot function in matlab. When you want to plot something, you don't go and edit the file which is somewhere in the matlab folder that makes matlab create plots. You just call the plot function : 'plot(x,y)' right?*

*Q: What is the equation for the recursive filter? *

*A: x_f(i) = a*x(i) + (1-a)*x_f(i-1); or you could write it:*

*x(i) = a*x(i) + (1-a)*x(i-1);*