Write a function get_distance that accepts two character vector inputs representing the names of two cities. The function returns the distance between them as an output argument called distance.

The given output is write,but I can't understand the warning and can't find out the problem. I find no-one with this problem, Please help someone kindly.

0 Commenti

Risposte (2)

Vinayak Mohite il 19 Giu 2020

Link diretto a questa risposta

Annulla Copia negli Appunti

Link diretto a questa risposta

Annulla Copia negli Appunti Modificato: Vinayak Mohite il 19 Giu 2020

The warning is there because the column headers of the file which is being read contain spaces, leading numbers, or other characters. But variables in MATLAB cannot have them.

You can get your original column header by setting PreserveVariableNames property to true. T = readtable( 'Distances.xlsx' , "PreserveVariableNames" ,true)

You are getting a correct answer because this is just a warning and not an error. This warning just to let the user know that his/her data has been modified.

1 Commento
Konkon Das il 21 Giu 2020

Link diretto a questo commento

Annulla Copia negli Appunti

Link diretto a questo commento

Annulla Copia negli Appunti Kindly please check the problem that I've faced afterwards. Konkon Das il 19 Giu 2020

Link diretto a questa risposta

Annulla Copia negli Appunti

Link diretto a questa risposta

Annulla Copia negli Appunti Hi Vinayak, Thanks a lot for your response.

I've tried a lot.But still now in stuck.First,I go to search for PreserveVariableNames property in doc file,but couldn't find probably for R2015a version. I search in net and then apply. But there is a warning like the below.

[Warning: Table variable names that were not valid MATLAB identifiers have been modified. Since table variable names must be unique, any table variable names that happened to match

the new identifiers also have been modified.]

After that I modified the code,but still showing the same warning.I couldn't find any other way. Can you help please.