Effacer les filtres
Effacer les filtres

Undefined operator '-' for input arguments of type 'cell'.

1 vue (au cours des 30 derniers jours)
Joseph Salerno
Joseph Salerno le 15 Sep 2018
I'm trying to input columns of data from a cell into an equation, with the hopes of it outputting multiple answers, one for each row. I've tried replacing parentheses with curly braces and using excessive parenthesis, but I can't figure it out. I'm entirely new to programming and matlab, so please go easy on me.
>> Data={'Helium','He',.0341,.0237;'Hydrogen','H2',.244,.0266;'Oxygen','O2',1.36,.0318;'Chlorine','Cl2',6.49,.0562;'Carbon dioxide','CO2',3.59,.0427}
Data =
5×4 cell array
{'Helium' } {'He' } {[0.0341]} {[0.0237]}
{'Hydrogen' } {'H2' } {[0.2440]} {[0.0266]}
{'Oxygen' } {'O2' } {[1.3600]} {[0.0318]}
{'Chlorine' } {'Cl2'} {[6.4900]} {[0.0562]}
{'Carbon dioxide'} {'CO2'} {[3.5900]} {[0.0427]}
>> Pressure=((.08206*300)/(20-{Data{:,4}}))-{Data{:,3}}/(20^2)

Réponses (1)

Image Analyst
Image Analyst le 15 Sep 2018
Try this:
Data={'Helium','He',.0341,.0237;'Hydrogen','H2',.244,.0266;'Oxygen','O2',1.36,.0318;'Chlorine','Cl2',6.49,.0562;'Carbon dioxide','CO2',3.59,.0427}
% Data =
% 5×4 cell array
% {'Helium' } {'He' } {[0.0341]} {[0.0237]}
% {'Hydrogen' } {'H2' } {[0.2440]} {[0.0266]}
% {'Oxygen' } {'O2' } {[1.3600]} {[0.0318]}
% {'Chlorine' } {'Cl2'} {[6.4900]} {[0.0562]}
% {'Carbon dioxide'} {'CO2'} {[3.5900]} {[0.0427]}
column3 = cell2mat(Data(:, 3))
column4 = cell2mat(Data(:, 4))
Pressure = ((.08206*300) ./ (20-column4)) - column3 ./ (20^2)

Catégories

En savoir plus sur Quantum Mechanics dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by