marix calculation with fixed and changing value

A=[1 2 ;
3 4;
5 6;],
B=[ 1 2 3;
4 5 6;
7 8 9;]
C=[1 2 3 4;
5 6 7 8;
9 10 11 12;]
D=[1 2 3 4 5;
6 7 8 9 10;
11 12 13 14 15;]
in matrix A,B,C,D the number of rows remain the same whereas the number of columns also get varied.
How to form the code for this condition and also how the graph can be plotted with fixed rows on the x axis and variable colums on the y axis.

Answers (1)

You do not indicate how the number of columns should vary, so we will arbitrarily choose the number randomly, and choose the contents randomly
numrows = 3;
%choose number of columns
numcols = randi(flintmax-1, 1, 1);
%now fill them with something
E = randi(15, numrows, numcols);
%now plot with the fixed rows on the x axis and the variable columns on the y axis
plot(E.')

3 Comments

thanks for your response but i receive the error stating Maximum variable size allowed by the program is exceeded in the command line (E = randi(15, numrows, numcols)).could you tell me how to get rid of this.
No, sorry, your question does not permit this problem to be removed.
In order to remove this problem, you would have to have a maximum limit on the number of columns, and that limit could not exceed 4.4 million per gigabyte of memory you have (assuming 3 rows.)
Your question requires any number of columns. I was already ruining the problem when I imposed an upper limit of 2^53 - 1 columns.
is it possible to have the number of columns with 5 different values to be 1:20,1:40,1:60,1:80 and 1:100 by assuming 10 rows.

Sign in to comment.

Asked:

on 30 Nov 2017

Commented:

on 30 Nov 2017

Community Treasure Hunt

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

Start Hunting!