When trying to do a regression role by utilizing a duty that is manually created, I have actually this error alerting: In one assignment A(:) = B, the number of elements in A and B must be the same.

You are watching: In an assignment a(:) = b, the number of elements in a and b must be the same.

The code I have are contained below(ols is a role created by me) and also I to be pretty sure it is no the difficulty in the function.


Separate from my answer, ns recommend friend re-think your storage variables. The method you index into estimates and also the rather looks prefer your space creating range in i beg your pardon to save the results, but then you also append those results to a various array. Girlfriend don\"t have to do both and saving them with indices is much far better because it allows you come pre-allocate the array.
You can shorten this by reversing the stimulate of the loop. The way, the an initial pass with the loop provides the complete size selection results and MATLAB doesn\"t spend time resizing the variety each time. In the prior instance we accomplished the same result by pre-allocating through nan.

It look at like among the outputs the your duty ols is not a scalar. The error you are seeing is the exact same as if friend executed


Community treasure Hunt

Find the prizes in MATLAB central and find how the community can help you!

begin Hunting!

An Error Occurred

Unable to complete the action because of transforms made come the page. Reload the page to view its update state.


choose a web Site

Choose a net site to acquire translated content where obtainable and see regional events and also offers. Based upon your location, we recommend the you select: .

select web site

How to Get ideal Site Performance

Select the China website (in Chinese or English) for ideal site performance. Other carolannpeacock.com nation sites are not optimized because that visits from your location.

See more: How Many Hours Is 3Pm To 8Am To 3Pm ? How Many Hours Total Are Between 8Am To 3Pm


Accelerating the pace of engineering and science

carolannpeacock.com is the leading developer that mathematical computer software for engineers and also scientists.