Why do I receive the error that arrays have incompatible sizes for this operation?
3 ビュー (過去 30 日間)
古いコメントを表示
When the code runs the error message reads:
- Arrays have incompatible sizes for this operation
- Error in line 5
- D=A:(A-C)/B:C;
clear all
A=('initial value:');
B=('number of values:');
C=('final value:');
D=A:(A-C)/B:C;
E=3412.14.*D;
F=(3412.14/2544.5).*D;
G=550.*D;
table(D',E',F',G','VariableNames',{'D','E','F','G'})
4 件のコメント
回答 (3 件)
Arif Hoq
2022 年 3 月 24 日
編集済み: Arif Hoq
2022 年 3 月 24 日
try this:
A=input('initial value:');
B=input('number of values:');
C=input('final value:');
% A=2;
% B=10;
% C=20;
D=A:(C-A)/B:C;
E=3412.14.*D;
F=(3412.14/2544.5).*D;
G=550.*D;
table(D',E',F',G','VariableNames',{'D','E','F','G'})
1 件のコメント
Arif Hoq
2022 年 3 月 24 日
A=2;
B=10;
C=20;
D=A:(A-C)/B:C;
E=3412.14.*D;
F=(3412.14/2544.5).*D;
G=550.*D;
table(D',E',F',G','VariableNames',{'D','E','F','G'})
whenever "final value-initial value"
A=2;
B=10;
C=20;
D=A:(C-A)/B:C;
E=3412.14.*D;
F=(3412.14/2544.5).*D;
G=550.*D;
table(D',E',F',G','VariableNames',{'D','E','F','G'})
Voss
2022 年 3 月 24 日
I guess those first three lines are supposed to be calls to input()
A=('initial value:');
B=('number of values:');
C=('final value:');
whos()
D=A:(A-C)/B:C;
As in:
A=input('initial value:');
B=input('number of values:');
C=input('final value:');
D=A:(A-C)/B:C;
1 件のコメント
Voss
2022 年 3 月 24 日
Also, note that this:
D=A:(C-A)/B:C;
gives you one more element than was requested:
A = 0; % initial value
B = 10; % number of values
C = 1; % final value
D=A:(C-A)/B:C;
numel(D)
It's better to use linspace():
D = linspace(A,C,B);
numel(D)
DEBABRATA jana
2023 年 9 月 14 日
編集済み: DEBABRATA jana
2023 年 9 月 14 日
B=imread('LOGO.bmp');
subplot(2,2,3),imshow(B),title('Watermark Image');
Wd=im2double(B);
DCTw=dct(Wd);
subplot(2,2,4),imshow(DCTw),title('DCT of Watermark Image');
DCTwi=(DCTw/2)+(DCTi/0.001);
WI=idct(DCTwi);
Arrays have incompatible sizes for this operation.
also
Arrays have incompatible sizes for this operation.
Error in DCTandIDCTwithWatermarkImage (line 17)
DCTwi=(DCTw/2)+(DCTi/0.001);
1 件のコメント
DGM
2023 年 9 月 14 日
編集済み: DGM
2023 年 9 月 14 日
The error means what it says. The arrays are not compatible sizes. So what size are they? Nobody knows what LOGO.bmp is, so nobody knows what size DCTw is. Similarly, nobody knows what size DCTi is or where it came from. You are the only person with access to that information.
Check the sizes of your arrays. If they came from the same source, one may have been subject to some operation (e.g. padding or differencing) which has altered its size.
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!