how to combine several graph becoming one (different length)

1 view (last 30 days)
Hi everyone,
I'm still a newbie in MATLAB programming and I need your help. I had calculated the mean of various frequency data and I want to combine the data becoming into one graph. For example,I calculated mean of 24 frequencies. Since the frequencies is different, the length was also different. Below is my MATLAB command.
%mean COM_08_mean=mean(COM_08_1cycle,2); (length=2001) COM_07_mean=mean(COM_07_1cycle,2); (length=1001) COM_068_mean=mean(COM_068_1cycle,2); (length=667) COM_066_mean=mean(COM_066_1cycle,2); COM_064_mean=mean(COM_064_1cycle,2); COM_062_mean=mean(COM_062_1cycle,2); COM_06_mean=mean(COM_06_1cycle,2); COM_058_mean=mean(COM_058_1cycle,2); COM_056_mean=mean(COM_056_1cycle,2); COM_054_mean=mean(COM_054_1cycle,2); COM_052_mean=mean(COM_052_1cycle,2); COM_05_mean=mean(COM_05_1cycle,2); COM_048_mean=mean(COM_048_1cycle,2); COM_046_mean=mean(COM_046_1cycle,2); COM_044_mean=mean(COM_044_1cycle,2); COM_042_mean=mean(COM_042_1cycle,2); COM_04_mean=mean(COM_04_1cycle,2); COM_038_mean=mean(COM_038_1cycle,2); COM_036_mean=mean(COM_036_1cycle,2); COM_034_mean=mean(COM_034_1cycle,2); COM_032_mean=mean(COM_032_1cycle,2); COM_03_mean=mean(COM_03_1cycle,2); COM_02_mean=mean(COM_02_1cycle,2); COM_01_mean=mean(COM_01_1cycle,2);
As I know, to combine several graph, we can use command horzcat but since the length was not matched I can't used that command.
Anyone can help me solved this problem?
Thanks in advance.

Answers (1)

Rik
Rik on 29 Sep 2017
I would advise two things:
  1. Rethink your data structure. When there is a number in a variable name, that usually means a cell, table or struct is better suited to the job.
  2. Use hold on after your first plot and then just repeat calls to plot after that. (or use them all in a single call to plot, see the documentation (doc plot) to see how that works)
  2 Comments
Rik
Rik on 2 Oct 2017
You're welcome. If this answered your question, please mark it as accepted answer. If you have follow up questions, you can post them here, or open a new question.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!