The least square with changing number of lines of matrix
์กฐํ ์: 1 (์ต๊ทผ 30์ผ)
์ด์ ๋๊ธ ํ์
Hello. I do some research. I have some measured data - vector, And I have my own linear equations ( - each line of this matrix equation belongs to specific measurement and the point is that sometimes some measurement can not ve taken account) And I have the result- probable vector solved by the least square method. Probable vector is matrix 1x6. Linear equation is 6xn and measured data is 1xn. Minimum of n is 6 and maximum of n is 24. Because I dont know mathlab, I use excel...but some program in mathlab would help me with time. Each time I have to change size of matrixes in excel. And this is pissing me of :-) can you tell me how to do it in mathlab? Actually the first question would be: how many of measurements do you have? Or what is size of vector of measurement data? This changes the size of my linear equation. Maybe I found something like erase the line of matrix. But maybe you found the better way. Thank you for any opinion. Girl from Czechia saying hi๐
๋๊ธ ์: 0
๋ต๋ณ (2๊ฐ)
Star Strider
2023๋
8์ 21์ผ
I am not certain what you want.
This calculates regressions on each column of โyโ and then plots it in the same colours as the original data โ
x = (1:6).';
y = randn(6,8);
B = [x, ones(size(x))] \ y
figure
hold on
for k = 1:size(y,2)
hp = plot(x, y(:,k), 'o:');
hp.MarkerFaceColor = hp.Color;
rl = [x, ones(size(x))] * B(:,k);
plot(x, rl, '-', 'Color',hp.Color, 'LineWidth',1)
end
hold off
grid
xlabel('X')
ylabel('Y')
title('Linear Regressions')
B = [x.^2, x, ones(size(x))] \ y
figure
hold on
for k = 1:size(y,2)
hp = plot(x, y(:,k), 'o:');
hp.MarkerFaceColor = hp.Color;
rl = [x.^2, x, ones(size(x))] * B(:,k);
plot(x, rl, '-', 'Color',hp.Color, 'LineWidth',1)
end
hold off
grid
xlabel('X')
ylabel('Y')
title('Quadratic Regressions')
B = [x.^3, x.^2, x, ones(size(x))] \ y
figure
hold on
for k = 1:size(y,2)
hp = plot(x, y(:,k), 'o:');
hp.MarkerFaceColor = hp.Color;
rl = [x.^3, x.^2, x, ones(size(x))] * B(:,k);
plot(x, rl, '-', 'Color',hp.Color, 'LineWidth',1)
end
hold off
grid
xlabel('X')
ylabel('Y')
title('Third-Order Regressions')
.
๋๊ธ ์: 4
Star Strider
2023๋
8์ 21์ผ
Not stupid at all.
I just fail to understand what you want to do from the description.
Bruno Luong
2023๋
8์ 21์ผ
ํธ์ง: Bruno Luong
2023๋
8์ 21์ผ
A = rand(24,6); % your full matrix
b = rand(24,1); % your measurements
% which data you want to remove?
removeidx = [1 4 24]; % removeidx = []; % to remove nothing
keep = setdiff(1:size(b,1), removeidx);
x = A(keep,:) \ b(keep,:)
That's all
๋๊ธ ์: 0
์ฐธ๊ณ ํญ๋ชฉ
์นดํ ๊ณ ๋ฆฌ
Help Center ๋ฐ File Exchange์์ Correlation and Convolution์ ๋ํด ์์ธํ ์์๋ณด๊ธฐ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!