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.

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
0 个评论
采纳的回答
Jan
2021-5-2
counter = 0;
for i=Arrayinput
for j=Arrayinput
...
counter = counter + 1;
subplot(alength, alength, counter);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!