Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 7-by-1.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello i have this problem
for i=1:341
for j=1:685
%y=net(x)
tst=reshape(inp_image(i,j,:),[1,10]);
y(i,j)= net(double(tst'));
end
end
0 Kommentare
Antworten (1)
Vedant Shah
am 28 Apr. 2025
Assuming that it is desired that the function ‘net’ returns a 7-by-1 array, there are several ways to assign its output to ‘y’, depending on the desired outcome:
3D Array Storage:
To store all outputs from ‘net’, define ‘y’ as a 3D array with dimensions ‘[341, 685, 7]’. This allows storage of the full 7-element output vector for each ‘(i,j)’ pair. To achieve this, replace:
y(i,j)= net(double(tst'));
with
y(i, j, :) = net(double(tst'));
2D Array Storage (Single Value):
If only a single value from the output is required (such as the first element or the sum of all elements), extract the relevant value and assign it to a 2D array `y` of size `[341, 685]`. For example, replace:
y(i,j)= net(double(tst'));
with
out = net(double(tst'));
y(i, j) = sum(out);
Cell Array Storage:
To keep ‘y’ as a 2D structure while storing all 7 elements for each ‘(i, j)’, use a cell array of size ‘[341, 685]’, where each cell contains a 7-by-1 vector. First, declare ‘y’ as follows:
y = cell(341, 685);
Then, replace:
y(i,j)= net(double(tst'));
with
y{i, j} = net(double(tst'));
The most suitable approach can be selected based on the specific requirements of the application and the intended use of the `net` function's output.
For more information, you can refer to the following documentation:
0 Kommentare
Siehe auch
Kategorien
Mehr zu Performance and Memory finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!