Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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]')

Risposta accettata

the cyclist
the cyclist il 12 Apr 2024
Modificato: the cyclist il 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.

Più risposte (0)

Categorie

Scopri di più su Animation in Help Center e File Exchange

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by