MATLAB smoothing question (noob)

This may sound like a repeat question, but I thought I had it figured out, but now it doesn't work anymore.

I have been provided a file called "data.txt"  that contails about 20,000 entries that look like:

6.03759999997,-0.893692672253
6.03749999991,0.457628786564
6.03740000007,-2.24501299858
6.03730000001,1.8089513778

col1 represents time_axis
col2 represents voltage

I use the import this into a variable: vdata.  Which in my right hand variables box shows up as vdata  <2003925x2>

Now I need to plot a smoothed version of volt_data against the same time axis.

Now I execute:
>>> sm_vdata = smooth(data)

which provides variable:  sm_vdata size <4007850x1>.

Obviously somethings wrong.  I need sm_vdata array to be the same size as v_data array with the same time values.

How do I do this?

Thanks in advance for any advice.
tmonteitAsked:
Who is Participating?
 
yuk99Commented:
SMOOTH convert your vdata matrix to a vector and smooth all together. You have to smooth col2 separately. I don't have Matlab now to test the code, but it should work:
time_data = vdata(:,1);
volt_data = vdata(:,2);
volt_data_sm = smooth(volt_data);
% then your can plot the data
plot(time_data,volt_data,'b.')
hold on
plot(time_data,volt_data_sm,'r-')
hold off
xlabel('Time')
ylabel('Voltage')

Open in new window

0
 
tmonteitAuthor Commented:
Also I need to put them both on a side-by-side plot.  How do I do that?


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.