Matrix dimensions must agree error
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Brendan Proaps
le 11 Sep 2020
Commenté : Brendan Proaps
le 11 Sep 2020
This is my code.
Temp_Coke = input('What is the current temperature of the Coke (deg F)? ', 's');
Temp_Fridge = input("What is the temperature of your friend's fridge (deg F)? ", 's');
Ideal_Coke_Temp = input('What is the ideal Coke drinking temperature (deg F)? ', 's');
k = 0.058;
t = log((Ideal_Coke_Temp-Temp_Fridge)/(Temp_Coke-Temp_Fridge))*(-1./k);
fprintf('It should take %d minutes to cool the Coke to %d degrees F from %d degrees F if my fridge has a temperature of %d degrees F.',t,Ideal_Coke_Temp,Temp_Coke,Temp_Fridge);
It's a simple code to find t(Time) from newtons law of cooling. However, when I run the code, the t = equation comes up as matrix dimensions must agree error and i dont know how to fix it.
0 commentaires
Réponse acceptée
Stephen23
le 11 Sep 2020
Wrap each input with str2double, e.g.:
Temp_Coke = str2double(input('What is the current temperature of the Coke (deg F)? ', 's'));
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!