I need Correct Subplot for This Code

5 次查看(过去 30 天)
Hi Everyone , I'm new to using MATLAB.
Please Help me , Thanks a lot.
This is my Homework Question :
The desired array is a subset of the number of data attributes (columns) in the CSV table file.
Note: In this exercise, two Nested FOR are used.
We want to have a subplot (for example 5 by 5) in which two attributes (columns) are displayed relative to each other.
The number of selected attributes is given as an array to the input function (for example as] [1 5 8 3] which means that we want to see the attributes mentioned in pairs in a 4 by 4 subplots.
Also for each case of Pairs of array elements plots we want to apply linear regression and then with the help of coefficients obtained from the function, polyfit draw a line graph on each plots.
Example of Correct Output Subplots
This Picture is The Example Of Correct Output Subplots For Array : [1 5 8 3]
This is my code but i have some problem , Based on this code, the output is not same as this picture ,i need correct subplot code :
Arrayinput = input ('Enter Array: ');
CASP = csvread('CASP.csv');
alength = length (Arrayinput);
for i=Arrayinput
for j=Arrayinput
i1=CASP(:,i);
j1=CASP(:,j);
%subplot(alength,alength,i); this is my problem , what is corrcet
%subplot for this Nested For Loop and array
plot(j1,i1,'.');
if (i==j)
title([num2str(i),'->',num2str(j),'y=x',' ','MSE = ']);
end
if (i~=j)
title([num2str(i),'->',num2str(j),' ','MSE = ']);
end
end
end

采纳的回答

Jan
Jan 2021-5-2
counter = 0;
for i=Arrayinput
for j=Arrayinput
...
counter = counter + 1;
subplot(alength, alength, counter);
  1 个评论
arash Moha
arash Moha 2021-5-2
编辑:arash Moha 2021-5-2
thanks a lot ,it is working. In this part of code, i need showing the column name in the title but it showed column number ,All of 10 columns name is (F1,F2,F3,F4,F5,F6,F7,F8,F9,RMSD) , what am i doing for this problem ?
if (i==j)
title([num2str(i),'->',num2str(j),'y=x',' ','MSE = ']);
end
if (i~=j)
title([num2str(i),'->',num2str(j),' ','MSE = ']);
end

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

产品


版本

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by