0

I have created two separate functions which collect data I have from two separate files. From this data, I want to make two separate histograms on the same plot.

Here is what I have written so far:

function var1 = simionRead28(test28)
test28 = dlmread('test28.dat', ',', 1, 0)

function var2 = simionRead29(test29)
test29 = dlmread('test29.dat', ',', 1, 0)

Here I have just defined the functions.

This is what I started doing with no success:

hist1(test28, -3:0.1:3)
hold on
hist2(test29, -3:0.1:3)
plot(hist1, hist2)

Side question: I've already defined a function var1 so I shouldn't have to even define var2, is there a way for me to collect the data using only one function?

Forgive me as I have only just started learning MATLAB today.

P_Drach
  • 25
  • 4

1 Answers1

0

it seems that your output and input in your functions are not right, you didn't assign the output of dlmread to the output variable of the function. instead of:

function var1 = simionRead28(test28)
test28 = dlmread('test28.dat', ',', 1, 0)

do:

function test28 = simionRead28()
test28 = dlmread('test28.dat', ',', 1, 0)

do the same for your second function and than plot it with:

hist(test28, -3:0.1:3)
hold on
hist(test29, -3:0.1:3)
user2999345
  • 4,195
  • 1
  • 13
  • 20