Filter löschen
Filter löschen

How to fix "Error using /, Matrix dimensions must agree"

2 Ansichten (letzte 30 Tage)
Rafael
Rafael am 12 Apr. 2024
Bearbeitet: the cyclist am 12 Apr. 2024
I'm just tryng to create a simple graph to display how some values change depedning on another variable, but for some reason it is not working. I do not know what to do.
Here is the code:
Fw=195*9.81;
CD=2.125;
BD_var = 0.1:0.01:CD;
MinFh=(Fw*CD*cosd(45))/(BD_var);
MaxFh=(Fw*CD*cosd(0))/(BD_var);
figure(2)
ax = axes;
plot(BD_var,MinFh)
title('Minimum Force on HC for Varying Distances')
axis ([0 inf 0 inf])
xlabel('Distance [m]')
ylabel('Force [N]')

Akzeptierte Antwort

the cyclist
the cyclist am 12 Apr. 2024
Bearbeitet: the cyclist am 12 Apr. 2024
Take a look at the documentation on Array vs. Matrix Operations.
I used element-wise division (using ./ rather than /) in your code:
Fw=195*9.81;
CD=2.125;
BD_var = 0.1:0.01:CD;
MinFh=(Fw*CD*cosd(45))./(BD_var);
MaxFh=(Fw*CD*cosd(0))./(BD_var);
figure(2)
ax = axes;
plot(BD_var,MinFh)
title('Minimum Force on HC for Varying Distances')
axis ([0 inf 0 inf])
xlabel('Distance [m]')
ylabel('Force [N]')
You might be interested in the free MATLAB Onramp tutorial.

Weitere Antworten (0)

Kategorien

Mehr zu Animation finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by