In an assignment A(:) = B, the number of elements in A and B must be the same.
1 view (last 30 days)
Show older comments
My code is:
pvals = 10:1:15;
nump = length(pvals);
for pidx = 1 : nump
p=pvals(pidx);
[x(pidx),y(pidx)]=solve('9*x(pidx)+8*y(pidx)=p','13*x(pidx)+14*y(pidx)=p+2','x(pidx)','y(pidx)');
end
plot(pvals,x)
The error is:
In an assignment A(:) = B, the number of elements in A and B must be the same.
Any help is appreciated! Thanks!
4 Comments
Kevin Phung
on 23 Jan 2019
unfortunately I don't have the toolbox, so I cant actually run your code :( sorry
Accepted Answer
Star Strider
on 23 Jan 2019
My version of the Symbolic Math Toolbox doesn’t like quoted strings, so I had to change your code a bit.
Try this:
syms p x y
pvals = 10:1:15;
nump = length(pvals);
for pidx = 1 : nump
p=pvals(pidx);
[xs(pidx),ys(pidx)]=solve([9*x+8*y==p, 13*x+14*y==p+2], [x y]);
end
plot(pvals,xs)
6 Comments
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!