Azzera filtri
Azzera filtri

Help with matlab Homework

3 visualizzazioni (ultimi 30 giorni)
Jeff
Jeff il 10 Dic 2023
Risposto: Walter Roberson il 10 Dic 2023
Hi :), can anyone please help me how to solve errors on my script, my code is running but some errors are coming up.
I have attached the files below.
Thank you Kindly

Risposte (1)

Walter Roberson
Walter Roberson il 10 Dic 2023
  • you should be using readtable() instead of readmatrix()
  • As far as MATLAB is concerned, totalValue = sum(data, productNames); is a request to total the array data along the dimension numbers stored in productNames and that syntax absolutely will not select variable names out of an array or table
Beyond that: it turns out that the first variable in your table is named productNames and the second is named Price
If I were working with that kind of data table, I would use readtable() and tell readtable() that the first column is to used as "row names". Then I would pull out all of the row names from the table and use those in the list dialog instead of hard-coding the list dialog entries. list dialog would return the indices of the chosen items, which could then be used as indices into the Price variable of the table, getting out a vector of prices, which you could then sum. All assuming that when an item is select that exactly one of them is to be purchased.

Categorie

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

Community Treasure Hunt

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

Start Hunting!

Translated by